feat: Add a --with-exit-status flag#270
Merged
taylorotwell merged 3 commits intoApr 26, 2024
Merged
Conversation
| new InputOption('dirty', '', InputOption::VALUE_NONE, 'Only fix files that have uncommitted changes'), | ||
| new InputOption('format', '', InputOption::VALUE_REQUIRED, 'The output format that should be used'), | ||
| new InputOption('cache-file', '', InputArgument::OPTIONAL, 'The path to the cache file'), | ||
| new InputOption('with-exit-status', '', InputOption::VALUE_NONE, 'Only fix files that have uncommitted changes'), |
Member
There was a problem hiding this comment.
I think the description here might be incorrect (copied and pasted from a few lines above?)
Contributor
Author
There was a problem hiding this comment.
Oops, didn't even see that. I'll fix that up and write any relevant tests as there seems to be interest in this feature.
Member
|
Hey @dshafik, thanks for the PR! I'll mark this as draft for now as you're still working on this. Feel free to mark as ready when you need another review. |
Contributor
Author
|
@driesvints Fixed up the one issue and added tests, this is ready for review now 🙏🏻 |
nunomaduro
requested changes
Apr 26, 2024
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a small feature,
--with-exit-statusthat will exit with either 1 or 0 if there are changed files or not. Essentially this is the same as running with the--testflag except that it also changes the files.This is helpful for tools such as Captain Hook (or really any pre-commit hook) which rely on the exit code to know if there were changes, so that it will fail and allow amending the commit manually.
it should be noted that while it seems the prevailing consensus is that you should just run
pintand then automatically add the changed files to the commit, however if you have additional working changes (e.g. you only staged part of the file, or made changes after staging it) then those changes would now be inadvertently included in the commit.Happy to add tests if this is a feature you feel would be worth contributing.
Docs PR: laravel/docs#9606