gpt4 book ai didi

git - 如何通过预提交 Hook 检测提交 --amend ?

转载 作者:太空狗 更新时间:2023-10-29 12:59:56 24 4
gpt4 key购买 nike

当我执行 commit --amend 时,如果提交已经被推送到远程存储库,那么它是不安全的提交。

我想检测不安全的提交——通过预提交钩子(Hook)修改并中止。

但是预提交钩子(Hook)没有参数。我不知道如何检测 --amend。

我该怎么办?

最佳答案

按照@Roger Dueck 的回答,最终做了:

#./.git/hooks/prepare-commit-msg

IS_AMEND=$(ps -ocommand= -p $PPID | grep -e '--amend');

if [ -n "$IS_AMEND" ]; then
return;
fi

关于git - 如何通过预提交 Hook 检测提交 --amend ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19387073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com