Skip to content

Commit

Permalink
pw_presubmit: Loosen commit message checks for Copybara imports
Browse files Browse the repository at this point in the history
Change-Id: I1f4349128be485f2a9c59b7309d2b2e53506a09b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/106711
Pigweed-Auto-Submit: Wyatt Hepler <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Reviewed-by: Rob Mohr <[email protected]>
  • Loading branch information
255 authored and CQ Bot Account committed Aug 15, 2022
1 parent 6433797 commit 050b254
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,17 +662,17 @@ def commit_message_format(_: PresubmitContext):
for line in lines:
_LOG.debug(line)

if not lines:
_LOG.error('The commit message is too short!')
raise PresubmitFailure

# Ignore Gerrit-generated reverts.
if ('Revert' in lines[0]
and 'This reverts commit ' in git_repo.commit_message()
and 'Reason for revert: ' in git_repo.commit_message()):
_LOG.warning('Ignoring apparent Gerrit-generated revert')
return

if not lines:
_LOG.error('The commit message is too short!')
raise PresubmitFailure

errors = 0

if len(lines[0]) > 72:
Expand All @@ -694,6 +694,13 @@ def commit_message_format(_: PresubmitContext):
lines[1])
errors += 1

# Ignore the line length check for Copybara imports so they can include the
# commit hash and description for imported commits.
if not errors and ('Copybara import' in lines[0]
and 'GitOrigin-RevId:' in git_repo.commit_message()):
_LOG.warning('Ignoring Copybara import')
return

# Check that the lines are 72 characters or less, but skip any lines that
# might possibly have a URL, path, or metadata in them. Also skip any lines
# with non-ASCII characters.
Expand Down

0 comments on commit 050b254

Please sign in to comment.