【发布时间】:2017-02-07 11:06:52
【问题描述】:
正如this 回答中提到的,可以在 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 .. 你应该 grepping "$1" 这是你的 commit-msg 的第一个参数 ..
-
此外,该正则表达式将传递任何在提交消息中任何位置具有 gh-[0-9] 的提交消息。例如“哦,我的 gh-0sh!”将通过测试:D