Skip to content

Commit

Permalink
chore(validator): limit commit title to 100 chars
Browse files Browse the repository at this point in the history
The default limit of commit titles is now set to 100 chars which allows
more expressiveness in some cases. But the recommended limit is still 70
chars.
  • Loading branch information
skyj committed Feb 16, 2022
1 parent 7518718 commit 0c04f0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ a **subject**:
<footer>
```

- The first line of the commit message (the "Subject") cannot be longer than 70
characters.
- The first line of the commit message (the "Subject") should not be longer
than 70 characters. However the limit is set to 100 characters to allow to
exceed the 70 characters when it's really needed.
- Any other line of the commit message cannot be longer 100 characters!
- The body and footer are optional, but depends on the type, information can be
mandatory.
Expand Down
18 changes: 9 additions & 9 deletions validator.bats
Original file line number Diff line number Diff line change
Expand Up @@ -330,27 +330,27 @@ BROKEN:
[[ $GLOBAL_SUBJECT == "message 3" ]]
}

@test "header length cannot be more than 70" {
run validate_header_length "01234567890123456789012345678901234567890123456789012345678901234567891"
@test "header length cannot be more than 100" {
run validate_header_length "01234567890123456789012345678901234567890123456789012345678901234567891234567890123456789012345678901"
[ "$status" -eq $ERROR_HEADER_LENGTH ]
}

@test "header length cannot be more than 70 with spaces" {
run validate_header_length "012345678 012345678 012345678 012345678 012345678 012345678 012345678 1"
@test "header length cannot be more than 100 with spaces" {
run validate_header_length "012345678 012345678 012345678 012345678 012345678 012345678 012345678 123456789 0123456789 0123456789"
[ "$status" -eq $ERROR_HEADER_LENGTH ]
}

@test "header length cannot be more than 150 with spaces. overriden" {
GLOBAL_MAX_LENGTH=150 validate_header_length "012345678 012345678 012345678 012345678 012345678 012345678 012345678 1"
}

@test "header length can be 70" {
run validate_header_length "0123456789012345678901234567890123456789012345678901234567890123456789"
@test "header length can be 100" {
run validate_header_length "0123456789012345678901234567890123456789012345678901234567890123456789123456789012345678901234567890"
[ "$status" -eq 0 ]
}

@test "header length can be 70 with spaces" {
run validate_header_length "012345678 012345678 012345678 012345678 012345678 012345678 012345678 "
@test "header length can be 100 with spaces" {
run validate_header_length "012345678 012345678 012345678 012345678 012345678 012345678 012345678 123456789 0123456789 01234567 "
[ "$status" -eq 0 ]
}

Expand Down Expand Up @@ -570,7 +570,7 @@ plop'
}

@test "overall validation invalid header length" {
MESSAGE='feat(plop): 01234567890123456789012345678901234567890123456789012345678901234567890'
MESSAGE='feat(plop): 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'

run validate "$MESSAGE"
[[ "$status" -eq $ERROR_HEADER_LENGTH ]]
Expand Down
2 changes: 1 addition & 1 deletion validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GLOBAL_FOOTER=""

# Overridable variables
GLOBAL_JIRA_TYPES="${GLOBAL_JIRA_TYPES:-feat fix}"
GLOBAL_MAX_LENGTH="${GLOBAL_MAX_LENGTH:-70}"
GLOBAL_MAX_LENGTH="${GLOBAL_MAX_LENGTH:-100}"
GLOBAL_JIRA_IN_HEADER="${GLOBAL_JIRA_IN_HEADER:-}"

GLOBAL_TYPE=""
Expand Down

0 comments on commit 0c04f0d

Please sign in to comment.