Skip to content

Conversation

@jawshooah
Copy link
Collaborator

Closes #146

Copy link
Owner

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?

@jawshooah
Copy link
Collaborator Author

@sds Definitely let me know if you think #amendment? could be implemented more elegantly. It's kind of a mess at the moment, but with the comments I think it's fairly straightforward.

@sds sds added the enhancement label Apr 8, 2015
@sds
Copy link
Owner

sds commented Apr 8, 2015

Thanks for addressing those comments, @jawshooah. This is great!

Merged in 7f23eb4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect git commit --amend in pre-commit hooks so staged files include everything in commit

2 participants