I have a post-commit hook that does stuff un ruby. It works very well but in some cases I would like to skip the code execution when I do a rebase or when I do a commit --amend.
If you want to detect git commit --amend from a hook, this is your best option
bash
if [[ $(ps -ocommand= -p $PPID) == "git commit --amend" ]]; then
echo "always allow git commit --amend"
exit 0
fi
ruby
parent=`ps -ocommand= -p #{Process.ppid}`.chomp
if parent == "git commit --amend"
# Always allow an amend
puts "always allow git commit --amend"
exit 0
end
git and shell aliases are expanded in the shell output, so this covers those cases too
Inspiration: https://github.com/brigade/overcommit/issues/146