【发布时间】:2019-10-25 16:31:10
【问题描述】:
我的提交信息将采用以下格式:
ANDROID-123 #commit Your commit message
ANDROID- 是固定关键字。
有什么建议吗?
【问题讨论】:
-
使用 git-hook? githooks.com
我的提交信息将采用以下格式:
ANDROID-123 #commit Your commit message
ANDROID- 是固定关键字。
有什么建议吗?
【问题讨论】:
Git 挂钩是在 git 工作流程的某些阶段自动运行的脚本。有一个commit-msg git 挂钩,用于在提交过程中检查或更改提交消息。有关详细信息,请参阅git scm documentation。
【讨论】:
您可以使用 gitlabhook,例如 pre-receive 挂钩,您将在其中为您的提交消息定义一个正则表达式,然后检查新的提交消息是否像您预定义的正则表达式。 它会是这样的:
REGEX="Your regex"
while read oldrev newrev refname ; do
#Validate commit message format
for COMMIT in `git rev-list $oldrev..$newrev`;
do
MESSAGE=`git cat-file commit $COMMIT | sed '1,/^$/d'`
if [[ $MESSAGE =~ $REGEX ]]; then
echo ""
else
echo -e "Error Message" >&2
exit 1
fi
done
【讨论】: