-
Notifications
You must be signed in to change notification settings - Fork 6
/
commit-msg
38 lines (34 loc) · 1.38 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Color codes
red='\033[0;31m'
yellow='\033[0;33m'
blue='\033[0;34m'
green='\033[0;32m'
NC='\033[0m' # No colors
printf "\n"
if ! [[ $(cat "$1") =~ ^((chore|docs|feat|fix|perf|refactor|style|ci|test)(\([a-zA-Z0-9]+\))?:|Merge\ pull) ]]; then
printf " /‾‾‾‾‾‾‾‾\n"
printf " 😼 < Meow! Please use semantic commit messages\n"
printf " \________\n\n"
printf " ${yellow}<type>${NC}[${green}<scope>${NC}]: ${blue}<short summary>${NC}\n"
printf "${yellow} │${green} │ ${blue}│\n"
printf "${yellow} │${green} │ ${blue}└─> Summary in present tense. Not capitalized. No period at the end. \n"
printf "${yellow} │${green} │\n"
printf "${yellow} │${green} └─> Scope: common|compiler|authentication|core|\n"
printf "${yellow} │ \n"
printf "${yellow} └─> Type: chore, docs, feat, fix, refactor, style, or test.\n"
exit 1
fi
while read -r line; do
# Skip comments
if [ "${line:0:1}" == "#" ]; then
continue
fi
if [ ${#line -gt 72} ]; then
echo -e "${yellow}Commit messages are limited to 72 characters.${NC}"
echo -e "The following commit message has ${red}${#line}${NC} characters."
echo "${line}"
exit 1
fi
done < "${1}"
exit 0