Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

matthewbjones
Copy link
Contributor

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 default

Screenshot 2025-02-10 at 5 00 32 PM

kamal build push skip error, via --skip-uncommitted-changes-check

Screenshot 2025-02-10 at 5 00 52 PM

kamal deploy error, by default

Screenshot 2025-02-10 at 5 01 27 PM

kamal deploy skip error, via --skip-uncommitted-changes-check

Screenshot 2025-02-10 at 5 03 27 PM

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.
@matthewbjones matthewbjones force-pushed the feature/uncommitted-now-errors branch from 02916ae to 9fadae3 Compare February 11, 2025 02:00
@matthewbjones
Copy link
Contributor Author

Not 100% sold on the flag name, wondering if --skip-uncommitted-changes would actually be better and more specific to what Kamal is actually doing.

@nickhammond
Copy link
Contributor

nickhammond commented Feb 11, 2025

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.

As far as the flag name, something with dirty in it would be good to match build dev #1357.

@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.

@matthewbjones
Copy link
Contributor Author

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 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

As far as the flag name, something with dirty in it would be good to match build dev #1357.

I'll think on that some. At the moment, I think --skip-uncommitted-changes is the clearest. However, now that Kamal supports purposefully including uncommitted changes for a dev build, maybe the error message I introduced can inform the user of their two choices (use --skip-uncommitted-changes to use the most-recent commit, or build dev to make a dev build using uncommitted changes.

@matthewbjones
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants