-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit-msg
executable file
·93 lines (87 loc) · 2.1 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/zsh
# git hook to validate commit-msg.
# We use gitmoji : https://gitmoji.carloscuesta.me/
# this hook validates that the first line of the commit message is a valid gitmoji.
#
# the first parameter is the name of the file which contains the commit message
validate_commit_msg() {
gitmojis=(
":art:"
":zap:"
":fire:"
":bug:"
":ambulance:"
":sparkles:"
":pencil:"
":rocket:"
":lipstick:"
":tada:"
":white_check_mark:"
":lock:"
":apple:"
":penguin:"
":checkered_flag:"
":robot:"
":green_apple:"
":bookmark:"
":rotating_light:"
":construction:"
":green_heart:"
":arrow_down:"
":arrow_up:"
":pushpin:"
":construction_worker:"
":chart_with_upwards_trend:"
":recycle:"
":whale:"
":heavy_plus_sign:"
":heavy_minus_sign:"
":wrench:"
":globe_with_meridians:"
":pencil2:"
":poop:"
":rewind:"
":twisted_rightwards_arrows:"
":package:"
":alien:"
":truck:"
":page_facing_up:"
":boom:"
":bento:"
":ok_hand:"
":wheelchair:"
":bulb:"
":beers:"
":speech_balloon:"
":card_file_box:"
":loud_sound:"
":mute:"
":busts_in_silhouette:"
":children_crossing:"
":building_contruction:"
":iphone:"
":clown_face:"
":egg:"
":see_no_evil:"
":camera_flash:"
":alembic:"
":mag:"
":wheel_of_dharma:"
":label:"
":seedling:"
":triangular_flag_on_post:"
":goal_net:"
":dizzy:"
":wastebasket:"
)
gitmojis_joined_with_pipes=${(j.|.)gitmojis}
regex="^($gitmojis_joined_with_pipes) : "
# validating the regex on the first line of the file
if $(head -1 $1 | grep -Eq "$regex"); then
exit 0
else
echo "Your commit message does not start with a gitmoji."
exit 1
fi
}
validate_commit_msg $1