github.com/bytedance/gopkg@v0.0.0-20240514070511-01b2cbcf35e1/check_branch_name.sh (about) 1 #!/usr/bin/env bash 2 3 basic="(master|develop|main)" 4 lints="((build|ci|chore|docs|feat|(hot)?fix|perf|refactor|revert|style|test)/.+)" 5 other="((release/v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+(\+[a-z0-9.]+)?)?)|revert-[a-z0-9]+)" 6 pattern="^(${basic}|${lints}|${other})$" 7 8 current=$(git status | head -n1 | sed 's/On branch //') 9 name=${1:-$current} 10 if [[ ! $name =~ $pattern ]]; then 11 echo "branch name '$name' is invalid" 12 exit 1 13 else 14 echo "branch name '$name' is valid" 15 fi