forked from techjoomla/maintenance-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commit-msg
executable file
·23 lines (18 loc) · 1.05 KB
/
commit-msg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
#title : commit-msg
#description : This script stops user from adding commit message in the format other than allowed one
#author : Manoj <[email protected]>
#date : 2017-07-13
#usage : Add the script in .git/hooks folder. Script should have executable permissions.
#==================================================================================================
# Install >> sudo apt-get install figlet
# figlet "Team Tekdi"
echo "\033[0;33m 😊 😀 Checking commit message format \033[1;37m"
# ((fix|ref|Issue|Task|Bug|Feature)\s*#?[0-9]+)
# ((fix|ref|Issue|Task|Bug|Feature)\s*#?[0-9]*\s(chore|feat|fix|test):\s)
# Regex to validate in commit msg
commit_regex='((fix|ref|Issue|Task|Bug|Feature|Feedback)\s*#?(([a-zA-Z]*-[0-9]*)|([0-9]*))\s(chore|feat|fix|test|style|refactor):\s)'
if ! grep -iqE "$commit_regex" "$1"; then
echo "\033[0;31m 😢 😭 Aborting commit. Your commit message needs to be in one of the formats. Check http://git.tekdi.net/snippets/24 for samples \033[39m" >&2
exit 1
fi