Skip to content

Commit 468bb01

Browse files
authored
feat: error message now red instead of green (#3)
1 parent 5d20d34 commit 468bb01

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

githooks/branch_validate.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
#!/usr/bin/env bash
1+
#!/bin/sh -e
22
LC_ALL=C
33

4+
NOCOLOR="\033[0m"
5+
RED="\033[0;31m"
6+
47
local_branch="$(git rev-parse --abbrev-ref HEAD)"
58

69
valid_branch_regex="^(bug|chore|devops|feat|fix|hotfix|release)\/[a-zA-Z0-9._-]+$"
710

8-
message="Commit failed. Branch names in this project must adhere to this contract: $valid_branch_regex. Please rename your branch and try again."
11+
message="Commit failed. Branch names in this project must follow this pattern: $valid_branch_regex. Please rename your branch and try again."
912

1013
if [[ ! $local_branch =~ $valid_branch_regex ]]
1114
then
12-
echo "$message"
15+
echo ${RED}$message${NOCOLOR}
1316
exit 1
1417
fi
1518

16-
exit 0
19+
exit 0

0 commit comments

Comments
 (0)