-
Notifications
You must be signed in to change notification settings - Fork 280
Include changes in last commit when running pre-commit hooks after git commit --amend
#167
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
Conversation
Returns the name of the command corresponding to the parent of the current process, which will be the calling git command when running hooks.
Returns true if the current hook run was initiated by amending a commit, false otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While right now there are no other git commands that have an --amend flag or a flag with --amend* as a prefix (that I know of), for the sake of future proofing we should constrain this regex to prevent false positives:
/\scommit\s.*\s--amend(\s|$)/You can also do an early return here since at this point you know this was an amend, saving a shell invocation below. (admittedly a micro-optimization)
return @amended if @amended = !(/--amend/ =~ cmd).nil?|
@sds Definitely let me know if you think |
|
Thanks for addressing those comments, @jawshooah. This is great! Merged in 7f23eb4. |
Closes #146