Skip to content

Commit 52d99b4

Browse files
chore(validator): allow to not check jira reference
1 parent 9ff599e commit 52d99b4

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

Diff for: README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ Behind the hood, the script use `git log` to list all the commit thus any syntax
197197
You can also use the pre-push commit validator, simply copy, `pre-push`, `validator.sh` and `check.sh` files
198198
in `.git/hooks` directory of your repository.
199199

200+
### OPTIONS
201+
202+
- if `COMMIT_VALIDATOR_NO_JIRA` environment variable is set, no validation is done on JIRA refs.
203+
200204
<!-- ROADMAP -->
201205

202206
## Roadmap
@@ -216,7 +220,7 @@ See the [open issues](https://github.com/lumapps/commit-msg-validator/issues) fo
216220
- [x] avoid trailing space
217221
- [x] allow automated revert commit
218222
- [ ] allow fixup! and squash! commit with an option
219-
- [ ] allow to not check JIRA reference with an option
223+
- [x] allow to not check JIRA reference with an option
220224
- [ ] enforce subject length (3 words at least)
221225

222226
<!-- CONTRIBUTING -->

Diff for: validator.bats

+5
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,11 @@ LUM-2345'
460460
[[ `need_jira "fix"` -eq 1 ]]
461461
}
462462

463+
@test "features and fixes commits don't need jira reference if set" {
464+
[[ `COMMIT_VALIDATOR_NO_JIRA= need_jira "feat"` -eq 0 ]]
465+
[[ `COMMIT_VALIDATOR_NO_JIRA= need_jira "fix"` -eq 0 ]]
466+
}
467+
463468
@test "other commits don't need jira reference" {
464469
[[ `need_jira "docs"` -eq 0 ]]
465470
[[ `need_jira "test"` -eq 0 ]]

Diff for: validator.sh

+14-10
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,20 @@ validate_trailing_space() {
208208
need_jira() {
209209
local TYPE=$1
210210

211-
case $TYPE in
212-
feat)
213-
echo 1
214-
;;
215-
fix)
216-
echo 1
217-
;;
218-
*)
219-
echo 0
220-
esac
211+
if [[ -v COMMIT_VALIDATOR_NO_JIRA ]]; then
212+
echo 0
213+
else
214+
case $TYPE in
215+
feat)
216+
echo 1
217+
;;
218+
fix)
219+
echo 1
220+
;;
221+
*)
222+
echo 0
223+
esac
224+
fi
221225
}
222226

223227
validate_jira() {

0 commit comments

Comments
 (0)