1 #!/usr/bin/env bash
2 3 current=$(git status | head -n1 | sed 's/On branch //')
4 name=${1:-$current}
5 if [[ ! $name =~ ^(((opt(imize)?|feat(ure)?|(bug|hot)?fix|test|refact(or)?|ci)/.+)|(main|develop)|(release-v[0-9]+\.[0-9]+)|(release/v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+(\+[a-z0-9.]+)?)?)|revert-[a-z0-9]+)$ ]]; then
6 echo "branch name '$name' is invalid"
7 exit 1
8 else
9 echo "branch name '$name' is valid"
10 fi
11