Skip to content

Fix/allow short jira ref #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ do
validate "$MESSAGE"
done <<< $COMMITS

echo "All commits succesfully checked"
echo "All commits successfully checked"
4 changes: 2 additions & 2 deletions git-commit-template
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ type(scope): subject
# kebab-case.

## Subject
# A brief but meaningfull description of the change. Here are some
# recommandation for writing your subject:
# A brief but meaningful description of the change. Here are some
# recommendation for writing your subject:
# - use the imperative, present tense: "change" not "changed" nor "changes"
# - don't capitalize first letter
# - no "." (dot) at the end
Expand Down
9 changes: 7 additions & 2 deletions validator.bats
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ plop"
@test "structure: valid commit message with header and multiple JIRA" {
COMMIT="plop plop

ABC-1234 DEF-1234"
ABC-1234 DE-1234"

validate_overall_structure "$COMMIT"
[[ $GLOBAL_HEADER == "plop plop" ]]
[[ $GLOBAL_BODY == "" ]]
[[ $GLOBAL_JIRA == "ABC-1234 DEF-1234" ]]
[[ $GLOBAL_JIRA == "ABC-1234 DE-1234" ]]
[[ $GLOBAL_FOOTER == "" ]]
}

Expand Down Expand Up @@ -549,6 +549,11 @@ LUM-2345'
[[ "$status" -eq 0 ]]
}

@test "feat with short jira ref should be validated" {
run validate_jira "feat" "AB-123"
[[ "$status" -eq 0 ]]
}

@test "overall validation invalid structure" {
MESSAGE='plop
plop'
Expand Down
2 changes: 1 addition & 1 deletion validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readonly HEADER_PATTERN="^([^\(]+)\(([^\)]+)\): (.+)$"
readonly TYPE_PATTERN="^(feat|fix|docs|gen|lint|refactor|test|chore)$"
readonly SCOPE_PATTERN="^([a-z][a-z0-9]*)(-[a-z0-9]+)*$"
readonly SUBJECT_PATTERN="^([a-z0-9].*[^ ^\.])$"
readonly JIRA_PATTERN="^([A-Z]{3,4}-[0-9]{1,6} ?)+$"
readonly JIRA_PATTERN="^([A-Z]{2,4}-[0-9]{1,6} ?)+$"
readonly JIRA_HEADER_PATTERN="^.*([A-Z]{3,4}-[0-9]{1,6}).*$"
readonly BROKE_PATTERN="^BROKEN:$"
readonly TRAILING_SPACE_PATTERN=" +$"
Expand Down