-
Notifications
You must be signed in to change notification settings - Fork 517
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
Raise error (instead of warn) when uncommitted git changes are detected #1409
base: main
Are you sure you want to change the base?
Raise error (instead of warn) when uncommitted git changes are detected #1409
Conversation
Changes the default behavior from printing a warning to printing an error message and exiting. New CLI introduced to suppress the error and proceed with previously-default behavior.
02916ae
to
9fadae3
Compare
Not 100% sold on the flag name, wondering if |
I like the idea, a couple of thoughts:
It looks like there's actually a builder helper method to help detect if it's building from a git clone or just a context, it'd be great to utilize this as a way to raise. What you're ultimately trying to raise for is specifically when it's using a git clone, there shouldn't be a need to raise when using the local build context. kamal/lib/kamal/configuration/builder.rb Line 126 in 6f29d4e
As far as the flag name, something with @djmb mentioned he'd be out this week, but it'd be good to get his thoughts on this since it'll change some of the kamal ergonomics. |
Kamal already uses this helper method to determine if to display the warning (and now the error), my check appears immediately after it: https://github.com/basecamp/kamal/pull/1409/files#diff-937ec1fc90a4c631a3f6f4095230378aa62fef153c3e1de477cfc2005dc2a7f9L22
I'll think on that some. At the moment, I think |
Hey @djmb, just wanted to touch base and see if you had any initial feedback? We've been using this version of Kamal the last few weeks, and it's already saved us once (by spitting out an error and exiting), when we overlooked committing a local change. |
There's more than just uncommitted changes to worry about. If you have a files that are not docker ignored but are git ignored, then they'll differ between a git clone build and a local build.
You can force an error when there are uncommitted changes via a custom pre-build hook which is what we do at 37signals. I do take the point about it being confusing for new users though. I'd like to get to a simpler approach overall for this - I don't know what that is to be honest (and maybe there isn't one) but I think adding the flag now might make that harder to do, so I think we should leave this right now. |
@djmb yeah, I wanted to avoid touching too many places with the introduction of the flag to revert back to previous behavior, but because I wasn't sure if some users of Kamal intentionally rely on the default functionality of it to ignore local changes I felt like there needed to be a flag to force the old behavior. It does still however, to me at least, seem like a big footgun that the default behavior is to "ignore" uncommitted local changes, and it continues to burn new users and on rare occasion, can burn even a seasoned Kamal user. Now, Kamal doesn't just "ignore" uncommitted changes, it does print out a warning message, but here's a few thoughts on that warning message:
@djmb Would you be open to separate PRs that tries to address these two points, separately? I can work on a PR that makes warning messages from Kamal a not-yellow color (or, change the docker command color to something other than yellow) I could also see if it is an easy & straightforward change to have the warning about uncommitted changes appear at the end of the Kamal output (somewhere around the |
After hanging around in the Discord for a few months, I've noticed that many beginners to Kamal experience "unexpected behavior" when it comes to making changes locally and then deploying, expecting that Kamal would've deployed their latest uncommitted changes.
Kamal would print out a warning message in yellow, but this can get lost in the sea of yellow messages and verbose output that Kamal prints out. Since the primary intended usage of Kamal is for you to first commit your changes before pushing/deploying, I believe it would be better to have the warning about ignoring uncommitted changes become an error, by default, and exit. If you purposefully want to have ignored, uncommitted local changes while pushing/deploying, you can suppress the error via
--skip-uncommitted-changes-check
, which results in Kamal printing out a warning in yellow but still proceeding (like it did by default prior to this change).kamal build push
error, by defaultkamal build push
skip error, via--skip-uncommitted-changes-check
kamal deploy
error, by defaultkamal deploy
skip error, via--skip-uncommitted-changes-check