File tree 5 files changed +34
-3
lines changed
5 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -233,6 +233,8 @@ in `.git/hooks` directory of your repository.
233
233
no validation is done on JIRA refs.
234
234
- if ` COMMIT_VALIDATOR_ALLOW_TEMP ` environment variable is not empty,
235
235
no validation is done on ` fixup! ` and ` squash! ` commits.
236
+ - if ` COMMIT_VALIDATOR_NO_REVERT_SHA1 ` environment variable is not empty,
237
+ no validation is done revert commits.
236
238
237
239
### Commit template
238
240
@@ -276,6 +278,8 @@ jobs:
276
278
- if ` no_jira` is not empty, no validation is done on JIRA refs.
277
279
- if `allow_temp` is not empty, no validation is done on `fixup!`
278
280
and `squash!` commits.
281
+ - if `no_revert_sha1` is not empty, no validation is done on revert
282
+ commits.
279
283
280
284
# # Add pre-commit plugin
281
285
@@ -303,9 +307,10 @@ Then run `pre-commit install --hook-type commit-msg` to install the
303
307
304
308
# ## Pre commit hook options
305
309
306
- - if `no_jira ` is set, no validation is done on JIRA refs.
307
- - if `allow_temp ` is set, no validation is done on `fixup!` and `squash!`
310
+ - if `no-jira ` is set, no validation is done on JIRA refs.
311
+ - if `allow-temp ` is set, no validation is done on `fixup!` and `squash!`
308
312
commits.
313
+ - if `no-revert-sha1` is set, no validation is done on revert commits.
309
314
310
315
<!-- ROADMAP -->
311
316
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ inputs:
13
13
allow_temp :
14
14
description : ' If not empty, no validation is done on `fixup!` and `squash!` commits.'
15
15
required : false
16
+ no_revert_sha1 :
17
+ description : ' If not empty, reverted sha1 commit is not mandatory in revert commit message.'
18
+ required : false
16
19
runs :
17
20
using : " composite"
18
21
steps :
31
34
env :
32
35
COMMIT_VALIDATOR_NO_JIRA : ${{ inputs.no_jira }}
33
36
COMMIT_VALIDATOR_ALLOW_TEMP : ${{ inputs.allow_temp }}
37
+ COMMIT_VALIDATOR_NO_REVERT_SHA1 : ${{ inputs.no_revert_sha1 }}
34
38
shell : bash
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ OPTIONS=$(getopt --long no-jira allow-temp -- "$@")
10
10
11
11
COMMIT_VALIDATOR_ALLOW_TEMP=
12
12
COMMIT_VALIDATOR_NO_JIRA=
13
+ COMMIT_VALIDATOR_NO_REVERT_SHA1=
13
14
14
15
while true ; do
15
16
case " $1 " in
16
17
--no-jira ) COMMIT_VALIDATOR_NO_JIRA=1; shift ;;
17
18
--allow-temp ) COMMIT_VALIDATOR_ALLOW_TEMP=1; shift ;;
19
+ --no-revert-sha1 ) COMMIT_VALIDATOR_NO_REVERT_SHA1=1; shift ;;
18
20
-- ) shift ; break ;;
19
21
* ) break ;;
20
22
esac
44
46
45
47
# print message so you don't lose it in case of errors
46
48
# (in case you are not using `-m` option)
47
- echo " Options: JIRA=$COMMIT_VALIDATOR_NO_JIRA , TEMP=$COMMIT_VALIDATOR_ALLOW_TEMP "
49
+ echo " Options: "
50
+ echo " JIRA=$COMMIT_VALIDATOR_NO_JIRA "
51
+ echo " TEMP=$COMMIT_VALIDATOR_ALLOW_TEMP "
52
+ echo " NO_REVERT_SHA1=$COMMIT_VALIDATOR_NO_REVERT_SHA1 "
48
53
printf " checking commit message:\n\n#BEGIN#\n%s\n#END#\n\n" " $MESSAGE "
49
54
50
55
validate " $MESSAGE "
Original file line number Diff line number Diff line change @@ -472,6 +472,8 @@ LUM-2345'
472
472
473
473
run validate_revert " $MESSAGE "
474
474
[[ " $status " -eq $ERROR_REVERT ]]
475
+ COMMIT_VALIDATOR_NO_REVERT_SHA1= run validate_revert " $MESSAGE "
476
+ [[ " $status " -eq $ERROR_REVERT ]]
475
477
}
476
478
477
479
@test " revert body with commit sha1 should be valid" {
@@ -483,6 +485,17 @@ LUM-2345'
483
485
484
486
run validate_revert " $MESSAGE "
485
487
[[ " $status " -eq 0 ]]
488
+ COMMIT_VALIDATOR_NO_REVERT_SHA1= run validate_revert " $MESSAGE "
489
+ [[ " $status " -eq 0 ]]
490
+ }
491
+
492
+ @test " revert body without sha1 should be valid with the flag" {
493
+ MESSAGE=' rerer
494
+
495
+ LUM-2345'
496
+
497
+ COMMIT_VALIDATOR_NO_REVERT_SHA1=1 run validate_revert " $MESSAGE "
498
+ [[ " $status " -eq 0 ]]
486
499
}
487
500
488
501
@test " features and fixes commits need jira reference" {
Original file line number Diff line number Diff line change @@ -242,6 +242,10 @@ validate_revert() {
242
242
local LINE=" "
243
243
local REVERTED_COMMIT=" "
244
244
245
+ if [[ ! -z " ${COMMIT_VALIDATOR_NO_REVERT_SHA1:- } " ]]; then
246
+ exit 0
247
+ fi
248
+
245
249
while IFS= read -r LINE ;
246
250
do
247
251
if [[ $LINE =~ $REVERT_COMMIT_PATTERN ]]; then
You can’t perform that action at this time.
0 commit comments