Skip to content

chore: fix up migration number fixer #14266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2024
Merged

chore: fix up migration number fixer #14266

merged 2 commits into from
Aug 14, 2024

Conversation

dannykopping
Copy link
Contributor

@dannykopping dannykopping commented Aug 14, 2024

Fixes:

  • more portable shebang
  • uses git mv which is more idiomatic for renames

This script still relies on folks needing a version of Bash not shipped with MacOS by default.

I'm using this version, so it works, but it doesn't work natively for folks running the default.

$ which bash
/opt/homebrew/bin/bash
$ bash --version
GNU bash, version 5.2.26(1)-release (aarch64-apple-darwin23.2.0)

# Default version
$ /bin/bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)

I created a Go equivalent in https://github.com/coder/coder/compare/dk/fix-migs which we could consider moving to.
It's a bit simpler (doesn't pull the given branch - trying to be more UNIXy), and requires a regex to match a file needing a rename, so it's more dumb but more explicit.

Signed-off-by: Danny Kopping <danny@coder.com>
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could consider importing lib.sh and verify Bash that way. This is not the only script that requires a more modern Bash I believe.

I'm a bit conflicted re: git mv, I agree it's not elegant but the file being renamed is not guaranteed to be staged, wouldn't that cause issues?

@mafredri
Copy link
Member

I created a Go equivalent in https://github.com/coder/coder/compare/dk/fix-migs which we could consider moving to.

Cool, I'm not particularly for out against so feel free to PR that work if you want to. Might be best to have a script or make target to shoot having to "go run".

It's a bit simpler (doesn't pull the given branch - trying to be more UNIXy),

We don't pull, just fetch. The fetch has a purpose in that it allows checking the remote, not just your local files. For me that was a big reason to write the script, when I had conflicts I could just run the script and enjoy the magic.

and requires a regex to match a file needing a rename, so it's more dumb but more explicit.

Why dumb it down? When I had conflicts I didn't really want to figure out what I need to do, just wanted the problem solved 😂

@dannykopping
Copy link
Contributor Author

We could consider importing lib.sh and verify Bash that way. This is not the only script that requires a more modern Bash I believe.

Hhmm interesting idea. You thinking of using lib.sh to replace the process with a call to /usr/bin/env bash so that regardless of the shebang we'll get the PATH bash, and on top of that validate a minimum version? Or just the latter?

I'm a bit conflicted re: git mv, I agree it's not elegant but the file being renamed is not guaranteed to be staged, wouldn't that cause issues?

Oof, good point.

We don't pull, just fetch. The fetch has a purpose in that it allows checking the remote, not just your local files. For me that was a big reason to write the script, when I had conflicts I could just run the script and enjoy the magic.

Fair point! I misspoke.


I think let's keep this script instead of the Go one (that took me like 10m with ChatGPT, Mr Snippet himself, doing most of the work 😄). Let's keep the lib.sh changes for a subsequent PR?

Signed-off-by: Danny Kopping <danny@coder.com>
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just the latter?

Just the latter 👍.

@dannykopping dannykopping merged commit c90e6d7 into main Aug 14, 2024
30 checks passed
@dannykopping dannykopping deleted the dk/fixup-mig-fix branch August 14, 2024 09:05
@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants