@@ -18,10 +18,7 @@ WHITE=
18
18
CYAN=
19
19
NC=
20
20
21
- #
22
21
# Set colour variables if the output should be coloured.
23
- #
24
-
25
22
set_colors () {
26
23
local default_color=$( git config --get hooks.goodcommit.color || git config --get color.ui || echo ' auto' )
27
24
if [[ $default_color == ' always' ]] || [[ $default_color == ' auto' && -t 1 ]]; then
@@ -34,10 +31,7 @@ set_colors() {
34
31
fi
35
32
}
36
33
37
- #
38
34
# Set the hook editor, using the same approach as git.
39
- #
40
-
41
35
set_editor () {
42
36
# $GIT_EDITOR appears to always be set to `:` when the hook is executed by Git?
43
37
# ref: http://stackoverflow.com/q/41468839/885540
@@ -49,10 +43,7 @@ set_editor() {
49
43
test -z " ${HOOK_EDITOR} " && HOOK_EDITOR=' vi'
50
44
}
51
45
52
- #
53
46
# Output prompt help information.
54
- #
55
-
56
47
prompt_help () {
57
48
echo -e " ${RED} $( cat << -EOF
58
49
e - edit commit message
62
53
) ${NC} "
63
54
}
64
55
65
- #
66
56
# Add a warning with <line_number> and <msg>.
67
- #
68
-
69
57
add_warning () {
70
58
local line_number=$1
71
59
local warning=$2
72
60
WARNINGS[$line_number ]=" ${WARNINGS[$line_number]} $warning ;"
73
61
}
74
62
75
- #
76
63
# Output warnings.
77
- #
78
-
79
64
display_warnings () {
80
65
if [ $SKIP_DISPLAY_WARNINGS -eq 1 ]; then
81
66
# if the warnings were skipped then they should be displayed next time
98
83
) ${NC} "
99
84
}
100
85
101
- #
102
86
# Read the contents of the commit msg into an array of lines.
103
- #
104
-
105
87
read_commit_message () {
106
88
# reset commit_msg_lines
107
89
COMMIT_MSG_LINES=()
@@ -159,10 +141,7 @@ get_all_match_positions() {
159
141
done <<< " $targets"
160
142
}
161
143
162
- #
163
144
# Validate the contents of the commmit msg agains the good commit guidelines.
164
- #
165
-
166
145
validate_commit_message () {
167
146
# reset warnings
168
147
WARNINGS=()
@@ -427,7 +406,6 @@ CHANGE_ID_AFTER="Bug|Issue|Test"
427
406
MSG=" $1 "
428
407
429
408
# Ensure that a unique Change-Id is present, and generate one if it is not.
430
- #
431
409
# Partially taken from Gerrit Code Review 3.3.0-56-gbcecc47463
432
410
add_change_id () {
433
411
clean_message=` sed -e '
@@ -578,9 +556,7 @@ _gen_changeid() {
578
556
git hash-object -t commit --stdin
579
557
}
580
558
581
- #
582
559
# It's showtime.
583
- #
584
560
585
561
set_colors
586
562
0 commit comments