Skip to content

Commit 160a25a

Browse files
committed
chore: better formatting on commit-msg hook
1 parent 7992aef commit 160a25a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.husky/commit-msg

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
#!/usr/bin/env sh
1+
#!/bin/bash
2+
3+
##
4+
# Git hook that enforces conventional commits
5+
# https://www.conventionalcommits.org
6+
##
7+
8+
RESET='\033[0m'
9+
GREEN='\033[0;32m'
10+
RED='\033[0;31m'
11+
212

313
if ! head -1 "$1" | grep -qE "^(feat|fix|chore|docs|test|style|refactor|perf|build|ci|revert)(!?)(\(.+?\))?: .{1,}$"; then
4-
echo "Aborting commit. Message must follow the pattern '<type>: <description>' (https://www.conventionalcommits.org/en/v1.0.0/)" >&2
14+
echo -e "${RED}\nAborting commit. Your commit message is invalid.\n" >&2
15+
echo "An example of a valid message is: " >&2
16+
echo " feat(login): add the 'remember me' checkbox" >&2
17+
echo "More details at: https://www.conventionalcommits.org/en/v1.0.0/#summary">&2
518
exit 1
619
fi
7-
if ! head -1 "$1" | grep -qE "^.{1,72}$"; then
8-
echo "Aborting commit. Your commit message is too long" >&2
20+
if ! head -1 "$1" | grep -qE "^.{1,50}$"; then
21+
echo -e "${RED}\nAborting commit. Your commit message is too long." >&2
22+
echo "Maximum length is 50 characters" >&2
923
exit 1
10-
fi
24+
fi

0 commit comments

Comments
 (0)