File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,10 @@ BROKEN:
328
328
[ " $status " -eq $ERROR_HEADER_LENGTH ]
329
329
}
330
330
331
+ @test " header length cannot be more than 150 with spaces. overriden" {
332
+ GLOBAL_MAX_LENGTH=150 validate_header_length " 012345678 012345678 012345678 012345678 012345678 012345678 012345678 1"
333
+ }
334
+
331
335
@test " header length can be 70" {
332
336
run validate_header_length " 0123456789012345678901234567890123456789012345678901234567890123456789"
333
337
[ " $status " -eq 0 ]
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ GLOBAL_HEADER=""
30
30
GLOBAL_BODY=" "
31
31
GLOBAL_JIRA=" "
32
32
GLOBAL_JIRA_TYPES=" ${GLOBAL_JIRA_TYPES:- feat fix} "
33
+ GLOBAL_MAX_LENGTH=" ${GLOBAL_MAX_LENGTH:- 70} "
33
34
GLOBAL_FOOTER=" "
34
35
35
36
GLOBAL_TYPE=" "
@@ -142,12 +143,8 @@ validate_header() {
142
143
143
144
validate_header_length () {
144
145
local HEADER=" $1 "
145
- local LENGTH
146
-
147
- LENGTH=" $( echo -n " $HEADER " | wc -c) "
148
-
149
- if [[ $LENGTH -gt 70 ]]; then
150
- echo -e " commit header length is more than 70 charaters"
146
+ if [[ ${# HEADER} -gt ${GLOBAL_MAX_LENGTH} ]]; then
147
+ echo -e " commit header length is more than ${GLOBAL_MAX_LENGTH} characters"
151
148
exit $ERROR_HEADER_LENGTH
152
149
fi
153
150
}
You can’t perform that action at this time.
0 commit comments