Skip to content

Commit f0eb02e

Browse files
Anis Da Silva Campossebastien-boulle
authored andcommitted
chore(pre-commit): allow fixups and revert
Now we can fixup locally. The github action should still block the merge though
1 parent e79cacc commit f0eb02e

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

check_message.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22

33
set -eu
44

5-
if [[ -v ZSH_NAME ]]; then
6-
setopt BASH_REMATCH
7-
setopt RE_MATCH_PCRE
8-
setopt KSH_ARRAYS
9-
fi
10-
115
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
12-
source $DIR/validator.sh
6+
# shellcheck source=validator.sh
7+
source "$DIR/validator.sh"
8+
9+
10+
if [[ "$1" == *MERGE_MSG ]]
11+
then
12+
# ignore merge message (merge with --no-ff without conflict)
13+
exit
14+
fi
1315

1416
MESSAGE=$(<"$1")
15-
echo "checking commit message: '${MESSAGE}'"
16-
validate "$MESSAGE"
1717

18-
echo "Message succesfully checked"
18+
FIRST_WORD=${MESSAGE%% *}
19+
if [[ "${FIRST_WORD,,}" == merge ]]
20+
then
21+
# ignore merge commits (merge after conflict resolution)
22+
exit
23+
24+
fi
25+
26+
# print message so you don't lose it in case of errors
27+
# (in case you are not using `-m` option)
28+
printf "checking commit message:\n\n#BEGIN#\n%s\n#END#\n\n" "$(grep -v "#" <<< "$MESSAGE")"
29+
30+
COMMIT_VALIDATOR_ALLOW_TEMP=1 COMMIT_VALIDATOR_NO_JIRA=1 validate "$MESSAGE"

0 commit comments

Comments
 (0)