正如this答案中所述,可以在Github提交中引用問題。如果提交格式不正確,是否可以拒絕Github上的提交?
是否有可能拒絕提交它是而不是格式化爲這樣?
例子:
fix gh-12 foo bar
是正確的
foo bar
將是錯誤
更新:
快到了,這仍然是不工作...有什麼想法?
我現在有以下幾點:.git/hooks/commit-msg
#!/bin/bash
commit_regex='(gh-[0-9]+|merge)'
error_msg="Aborting commit. Your commit message is missing either a Github Issue ('gh-1111') or 'Merge'."
if ! grep -E "$commit_regex" <<< "$0"; then
echo "$error_msg" >&2
exit 1
fi
$ 0就是你的.git/hooks/commit-msg ..你應該對你的commit-msg的第一個參數grep「$ 1」。 – rasjani
也是這樣,正則表達式會傳遞任何提交消息, - [0-9]提交消息中的任何地方。例如「哦,我的gh-0sh!」將通過測試:D – rasjani