【发布时间】:2020-08-06 16:35:28
【问题描述】:
我有一个 pre-receive 挂钩来检查运行 Git 项目的命名约定:
valid_branch_regex="^(master|release-[0-9]{4}-[0-9]{2}|[A-Z|0-9]{3,6}-[0-9]+-.*)"
while read oldrev newrev refname; do
echo "$refname : $oldrev ~ $newrev"
current_branch=$refname
short_current_branch="$(echo $current_branch | sed 's/refs\/heads\///g')"
done
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract:\
$valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."
if [[ ! $short_current_branch =~ $valid_branch_regex ]]
then
echo "$message"
exit 1
fi
exit 0
问题是我想绕过在应用脚本之前推送的分支。有什么想法可以改善我目前的逻辑吗?
谢谢!
【问题讨论】: