Skip to content

Commit 3f2d292

Browse files
fallbergbblacey
authored andcommitted
Add git commit message hook to the mystools bundle (#1067)
The message hook validates that the c ommit message follows the MySensors requirements. More specifically, it checks that - Commit message does not exceed a line length of 72 characters - Commit title start with an uppercase character - Commit title does not end with a period ('.') Fixes #672
1 parent eb83946 commit 3f2d292

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

.mystools/hooks/commit-msg.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
too_long_lines=$(awk 'length>72' $1)
3+
if [[ ! -z $too_long_lines ]]; then
4+
echo "Too long commit message lines:" $too_long_lines
5+
has_failed=1
6+
fi
7+
8+
leading_lowercases=$(awk 'NR==1' $1 | awk '/^[[:lower:][:punct:]]/')
9+
if [[ ! -z $leading_lowercases ]]; then
10+
echo "Leading lowercase in subject:" $leading_lowercases
11+
has_failed=1
12+
fi
13+
14+
trailing_periods=$(awk 'NR==1' $1 | awk '/(\.)$/')
15+
if [[ ! -z $trailing_periods ]]; then
16+
echo "Trailing periods in subject:" $trailing_periods
17+
has_failed=1
18+
fi
19+
20+
if [[ ! -z $has_failed ]]; then
21+
echo "Please recommit with a new commit message."
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)