[英]Is there way to run git hook before/after 'git add' command?
[英]Add a flag to a git command to be used in a hook
我有一個git鈎子,每當我按下它都會運行一個測試:
.git/hooks/pre-push
cd $GOPATH/src/lab.omitted.com/omitted/tools/tribute/
./run-newman-non-dkr.sh
我想在那里放一個標志,這樣我就可以在不運行測試的情況下進行推送:
if [[ $* == *--skiptest* ]]
then
echo Skipping Newman Test
else
echo --- Running Newman Test
cd $GOPATH/src/lab.omitted.com/omitted/tools/tribute/
./run-newman-non-dkr.sh
fi
但是我不能用那個標志運行git push
$ git push --set-upstream origin feature/417/itp-update --skiptest
error: unknown option `skiptest'
有沒有解決的辦法?
您不能在推送中添加標志。
但是你可以告訴git忽略鈎子
使用
--no-verify
,掛鈎將被完全繞過。
git push --no-verify
否則,您可以執行以下操作之一:
git notes add ....
到帶有所需標志的提交中,並在鈎子中再次讀取 您也可以在環境中設置變量,git會通過這些變量。 選擇一些亂碼前綴,對於“ my git hook”和“ pre-push”來說, mghpp
怎么樣? 然后
mghppbypass= git push
然后在你的git hook中
if [[ ${mghppbypass+set} = set ]]; then
echo bypassing pre-push tests
else
the pre-push tests
fi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.