我希望我的提交消息遵循某种格式,即
Jira-ticket STORY|BUG|REFACTOR jira description
。
示例:
BLRG-1234 BUG ui alignment issue
目前我正在使用以下正则表达式:
#!/usr/bin/env bash
commit_regex='(BLRG)+(-)(\d)+\s+(STORY|BUG|REFACTOR)\s+(([a-zA-Z0-9]+)(\s|_)*)+'
error_msg="Commit message format is incorrect"
if ! grep -qE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi
当我输入
BLRG-1234 BUG ui alignment issue
作为提交消息时,我无法提交。有人可以告诉我必须使用什么正则表达式吗?
我通过对我的 commit_regex 进行以下更改来修复它 将
(-)(\d)
替换为 -[0-9]
,将 \s
替换为 [[:blank:]]
工作拒绝
commit_regex='(RXRENUCLMR)+-[0-9]+[[:blank:]](STORY|BUGFIX|REFACTOR|MERGE|DOCUMENT)[[:blank:]](([a-zA-Z0-9]+)(\s|_)*)+'