Skip to content

Commit

Permalink
chore(validator): allow to not check jira reference
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-boulle committed Aug 20, 2020
1 parent 9ff599e commit 52d99b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ Behind the hood, the script use `git log` to list all the commit thus any syntax
You can also use the pre-push commit validator, simply copy, `pre-push`, `validator.sh` and `check.sh` files
in `.git/hooks` directory of your repository.

### OPTIONS

- if `COMMIT_VALIDATOR_NO_JIRA` environment variable is set, no validation is done on JIRA refs.

<!-- ROADMAP -->

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

<!-- CONTRIBUTING -->
Expand Down
5 changes: 5 additions & 0 deletions validator.bats
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ LUM-2345'
[[ `need_jira "fix"` -eq 1 ]]
}

@test "features and fixes commits don't need jira reference if set" {
[[ `COMMIT_VALIDATOR_NO_JIRA= need_jira "feat"` -eq 0 ]]
[[ `COMMIT_VALIDATOR_NO_JIRA= need_jira "fix"` -eq 0 ]]
}

@test "other commits don't need jira reference" {
[[ `need_jira "docs"` -eq 0 ]]
[[ `need_jira "test"` -eq 0 ]]
Expand Down
24 changes: 14 additions & 10 deletions validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,20 @@ validate_trailing_space() {
need_jira() {
local TYPE=$1

case $TYPE in
feat)
echo 1
;;
fix)
echo 1
;;
*)
echo 0
esac
if [[ -v COMMIT_VALIDATOR_NO_JIRA ]]; then
echo 0
else
case $TYPE in
feat)
echo 1
;;
fix)
echo 1
;;
*)
echo 0
esac
fi
}

validate_jira() {
Expand Down

0 comments on commit 52d99b4

Please sign in to comment.