Add length exemption for revert commit messages

This will make it so revert commits can make it through
without needing truncation done on the original commit message

Test Plan:
  - Amend this commit and make the commit message really long
  - Run script/lint_commit_message
  - It will output an error message about length
  - Amend the commit again and put "Revert" at the beginning
    of the subject line.
  - Run the linter again
  - It will not print out the error now

Change-Id: Id2b57e202a0bbd46dbc8de29d9bcc984c9c5fe99
Reviewed-on: https://gerrit.instructure.com/109316
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
Clay Diffrient 2017-04-20 21:39:19 -06:00
parent e8c3368aca
commit 679f1cb699
1 changed files with 4 additions and 2 deletions

View File

@ -37,9 +37,11 @@ end
SUBJECT_MAX_LINE_LEN = 75
SUBJECT_IDEAL_LINE_LEN = 65
if subject.size > SUBJECT_MAX_LINE_LEN
length_exemption_regex = /^Revert/
if subject.size > SUBJECT_MAX_LINE_LEN && subject !~ length_exemption_regex
comment "error", 1, "subject line can't exceed #{SUBJECT_MAX_LINE_LEN} chars (ideally keep it well under #{SUBJECT_IDEAL_LINE_LEN})", true
elsif subject.size > SUBJECT_IDEAL_LINE_LEN
elsif subject.size > SUBJECT_IDEAL_LINE_LEN && subject !~ length_exemption_regex
comment "warn", 1, "subject line shouldn't exceed #{SUBJECT_IDEAL_LINE_LEN} chars", true
end