We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6c2330f commit 88a6f26Copy full SHA for 88a6f26
1 file changed
pre_commit_hooks/check-branch-name.sh
@@ -1,9 +1,10 @@
1
#!/bin/bash
2
3
-while getopts r: flag
+while getopts r:e: flag
4
do
5
case "${flag}" in
6
r) BRANCH_NAME_REGEX=${OPTARG};;
7
+ e) EXCLUDE_BRANCH_REGEX=${OPTARG};;
8
*) echo "Invalid flag provided ($flag)"; exit 1;
9
esac
10
done
@@ -24,10 +25,15 @@ fi
24
25
26
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
27
28
+if [[ $BRANCH_NAME =~ $EXCLUDE_BRANCH_REGEX ]]; then
29
+ exit 0
30
+fi
31
+
32
if ! [[ $BRANCH_NAME =~ $BRANCH_NAME_REGEX ]]; then
33
echo "*** Commit interrupted ***"
34
echo "Your branch name does not match the naming convention."
- echo "Branch names should match \"$BRANCH_NAME_REGEX\"..."
35
+ echo "Branch names should match \"$BRANCH_NAME_REGEX\"."
36
+ echo "Your branch is named \"$BRANCH_NAME\"..."
37
38
exit 1
39
fi
0 commit comments