diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-12-19 16:04:01 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-12-20 05:43:24 +0000 |
commit | e04fdf59bfcd2085e3e960e929970f5c94bb2b78 (patch) | |
tree | 788ec358d0b36102824dc03bc41477c3feffc0e4 /tools/validate-commit.py | |
parent | 8d23cdd0fad953f8900da64a27eeea09a99fcf6a (diff) |
tools: exclude Revert prefixes from 80 chars limit
When commits are reverted, the subject line might exceed 80 chars.
Adjust the pre-commit hook to gracefully handle a higher length and let
validate-commit.py (as used by Petri-Dish) validate the original subject
length.
Change-Id: I54f2a99f95b7fca2f683aa1e98f0349dcf4ed1b7
Reviewed-on: https://code.wireshark.org/review/31120
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools/validate-commit.py')
-rwxr-xr-x | tools/validate-commit.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/validate-commit.py b/tools/validate-commit.py index bc1016365a..64d3e77893 100755 --- a/tools/validate-commit.py +++ b/tools/validate-commit.py @@ -95,13 +95,24 @@ def tools_dir(): return os.path.join(srcdir, 'tools') +def extract_subject(subject): + '''Extracts the original subject (ignoring the Revert prefix).''' + subject = subject.rstrip('\r\n') + prefix = 'Revert "' + suffix = '"' + while subject.startswith(prefix) and subject.endswith(suffix): + subject = subject[len(prefix):-len(suffix)] + return subject + + def verify_body(body): old_lines = body.splitlines(True) is_good = True if len(old_lines) >= 2 and old_lines[1].strip(): print('ERROR: missing blank line after the first subject line.') is_good = False - if len(old_lines[0]) > 80: + cleaned_subject = extract_subject(old_lines[0]) + if len(cleaned_subject) > 80: # Note that this is currently also checked by the commit-msg hook. print('Warning: keep lines in the commit message under 80 characters.') is_good = False |