我有一个 post-commit 钩子,它在 ruby 中做一些事情。它工作得很好,但在某些情况下,我想在执行git rebase
or时跳过代码执行git commit --amend
。
有人知道在这些情况下我如何无法触发提交后挂钩或任何解决方法吗?
我有一个 post-commit 钩子,它在 ruby 中做一些事情。它工作得很好,但在某些情况下,我想在执行git rebase
or时跳过代码执行git commit --amend
。
有人知道在这些情况下我如何无法触发提交后挂钩或任何解决方法吗?
变基时,文件夹中有一个名为rebase-merge
present 的.git
目录。这可能是一种在 a 期间禁用钩子的方法( btwrebase
的开始由钩子指示)。rebase
pre-rebase
但是--amend
,我帮不了你。
如果你想从钩子中检测 git commit --amend ,这是你最好的选择
重击
if [[ $(ps -ocommand= -p $PPID) == "git commit --amend" ]]; then
echo "always allow git commit --amend"
exit 0
fi
红宝石
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 和 shell 别名在 shell 输出中扩展,所以这也涵盖了这些情况