@@ -7,7 +7,7 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
7
7
8
8
### Version controlled git-hooks:
9
9
* ProjectDirectory/.githooks
10
- * < b > pre-commit</ b >
10
+ > ### pre-commit ::
11
11
``` sh
12
12
# ------------------- Check for white-space error -------------------- #
13
13
# Check if this is the initial commit
@@ -31,7 +31,7 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
31
31
exit 0
32
32
fi
33
33
```
34
- * < b > prepare-commit-msg< /b >
34
+ > # ## prepare-commit-msg ::
35
35
` ` ` sh
36
36
# Append commit message with STRY, DEF, BAK tickets or MAINT
37
37
@@ -51,48 +51,65 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
51
51
then
52
52
# echo "branch name cotains hyphen"
53
53
separator=" -"
54
- else
55
- separator=" "
56
54
fi
57
55
58
56
arr=(${CURRENT_BRANCH// ${separator} / } )
59
57
CURRENT_BRANCH=${arr[0]}
60
58
61
- echo " CURRENT_BRANCH = " ${CURRENT_BRANCH} #
59
+ # echo "CURRENT_BRANCH = "${CURRENT_BRANCH} #
62
60
63
61
# PREFIX_REGEX="((DEF|BAK|STRY|MAINT|def|bak|stry|maint|TNTC)[0-9]*)(_*).*"
64
62
65
63
PREFIX_REGEX=" ((DEF|BAK|STRY|MAINT|def|bak|stry|maint|TNTC)[0-9]*)"
66
64
COMMIT_MESSAGE=$( cat $COMMIT_MSG_FILE )
65
+ MIN_COMMIT_LENGTH=5
66
+
67
+ if [[ ${# COMMIT_MESSAGE} < $MIN_COMMIT_LENGTH ]]
68
+ then
69
+ echo ' Commit message is too short..... Commit --------------------------> [ABORTED]'
70
+ exit 1;
71
+ fi
72
+
73
+
67
74
if [[ $CURRENT_BRANCH =~ $PREFIX_REGEX ]]
68
75
then
69
76
TICKET=" ${BASH_REMATCH[0]} "
70
77
# echo "TICKET IS = "${TICKET}
71
78
72
- if [[ $COMMIT_MESSAGE =~ $TICKET ]]
79
+ if [[ ! $COMMIT_MESSAGE =~ $TICKET ]]
73
80
then
74
- exit 0;
75
- fi
76
-
77
- echo "Ticket '${TICKET}', matched in current branch name, appended to commit message."
78
-
79
- if [[ $COMMIT_MESSAGE == "TEST"* ]] || [[ $COMMIT_MESSAGE == "test"* ]] || [[ $COMMIT_MESSAGE == "MAINT"* ]] || [[ $COMMIT_MESSAGE == "maint"* ]]
80
- then
81
- echo ${COMMIT_MESSAGE}" - "${TICKET} > $COMMIT_MSG_FILE
81
+ echo " Ticket '${TICKET} ', matched in current branch name, appended to commit message."
82
+
83
+ if [[ $COMMIT_MESSAGE == " TEST" * ]] || [[ $COMMIT_MESSAGE == " test" * ]] || [[ $COMMIT_MESSAGE == " MAINT" * ]] || [[ $COMMIT_MESSAGE == " maint" * ]]
84
+ then
85
+ echo ${COMMIT_MESSAGE} " - " ${TICKET} > $COMMIT_MSG_FILE
86
+ echo " Ticket '${TICKET} ', was appended to the commit message!......................"
87
+ echo " Commit Status >------------------------------------------------> [SUCCESSFUL]"
88
+ else
89
+ echo " TEST: ${COMMIT_MESSAGE} - ${TICKET} " > $COMMIT_MSG_FILE
90
+ echo " TEST: was pre-fixed to the commit message...................................."
91
+ echo " Commit Status >------------------------------------------------> [SUCCESSFUL]"
92
+ fi
82
93
else
83
- echo "TEST: ${COMMIT_MESSAGE} - ${TICKET}" > $COMMIT_MSG_FILE
84
- echo "TEST: was pre-fixed to the commit message"
94
+ if [[ $COMMIT_MESSAGE != " TEST" * ]] && [[ $COMMIT_MESSAGE != " test" * ]] && [[ $COMMIT_MESSAGE != " MAINT" * ]] && [[ $COMMIT_MESSAGE != " maint" * ]]
95
+ then
96
+ echo " TEST: ${COMMIT_MESSAGE} " > $COMMIT_MSG_FILE
97
+ echo " TEST: was pre-fixed to the commit message...................................."
98
+ echo " Commit Status >------------------------------------------------> [SUCCESSFUL]"
99
+ fi
85
100
fi
86
101
87
102
elif [[ $COMMIT_MESSAGE == " MAINT" * ]] || [[ $COMMIT_MESSAGE == " TEST" * ]] || [[ $COMMIT_MESSAGE == " test" * ]] || [[ $COMMIT_MESSAGE == " maint" * ]]
88
103
then
104
+ echo " Commit Status >------------------------------------------------> [SUCCESSFUL]"
89
105
exit 0;
90
106
else
91
107
echo " TEST: " ${COMMIT_MESSAGE} > $COMMIT_MSG_FILE
92
- echo "TEST: was pre-fixed to the commit message"
108
+ echo " TEST: was pre-fixed to the commit message...................................."
109
+ echo " Commit Status >------------------------------------------------> [SUCCESSFUL]"
93
110
fi
94
111
` ` `
95
- * < b > pre-push< /b >
112
+ > # ## pre-push ::
96
113
` ` ` sh
97
114
# ------------------- Compile Maven Project -------------------- #
98
115
@@ -116,8 +133,9 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
116
133
fi
117
134
cd $CWD
118
135
` ` `
119
- # ## Master git-hooks installer:
120
- * ProjectDirectory/install_hooks.sh
136
+
137
+ > # # Master git-hooks installer:
138
+ * ProjectDirectory/install_hooks.sh
121
139
` ` ` sh
122
140
# Installs the hooks into your githooks directory
123
141
@@ -140,16 +158,15 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
140
158
fi
141
159
142
160
echo " Hooks installed successfully"
143
-
144
161
` ` `
145
162
146
- # ## Makefile for setups:
147
- * makefile
148
- ` ` ` makefile
163
+ > # # Makefile for setups:
164
+ * makefile
165
+ ` ` ` makefile
149
166
all: say_hello change_hooks_config
150
167
# all: say_hello generate_textfiles clean_textfiles
151
168
# Note - First Line of the make file is always the default goal/target
152
- # so, it gets executed everytime
169
+ # so, it gets executed everytime
153
170
say_hello:
154
171
echo " Hello World"
155
172
@@ -173,7 +190,7 @@ This project contains a Maven project with tests. Git-Hooks are configured and b
173
190
change_hooks_config:
174
191
echo " Modifying git hook config"
175
192
git config core.hooksPath .githooks
176
- ` ` `
193
+ ` ` `
177
194
178
195
< ! -- < p align=" center" >
179
196
< img src=" ./img/why.png" alt=" Statoscope example" width=" 650" >
0 commit comments