问题描述
我使用下面提到的代码用正则表达式验证分支名称,但在无效的情况下它工作正常但在有效的情况下它也给出相同的消息并且它没有按预期创建分支名称。
LC_COLLATE='C'
local_branch="$(git rev-parse --abbrev-ref HEAD)"
valid_branch_regex="^(feature|merge|project|release|revert|scratch|story|track)\/[-a-z0-9_/]+$"
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex."
if [[ ! $local_branch =~ $valid_branch_regex ]]; then
echo "$message"
exit 1
fi
exit 0
结果:-
无法创建分支。预接收挂钩失败。
scripts/git-branch-name-test.sh:失败,退出状态为 1 你的分支名称有问题。本项目中的分支名称必须遵守本合同:^(feature|merge|project|release|revert|scratch|story|track)/[-a-z0-9_/]+$。
有人可以帮我解决这个问题吗?我错过了什么吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)