Presubmit: Add check to support b/xxx entry in bug reference.

NOTRY=True

Bug: webrtc:8197
Change-Id: I98c22bd5cb5ea22e7280d76c62c085816cb19100
Reviewed-on: https://webrtc-review.googlesource.com/3280
Commit-Queue: Charu Jain <charujain@google.com>
Reviewed-by: Henrik Kjellander <kjellander@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19972}
This commit is contained in:
charujain 2017-09-25 13:25:45 +02:00 committed by Commit Bot
parent ec78918e85
commit 81a58c7d81
2 changed files with 14 additions and 2 deletions

View file

@ -480,7 +480,7 @@ def CheckCommitMessageBugEntry(input_api, output_api):
bug = bug.strip()
if bug.lower() == 'none':
continue
if ':' not in bug:
if 'b/' not in bug and ':' not in bug:
try:
if int(bug) > 100000:
# Rough indicator for current chromium bugs.
@ -491,7 +491,7 @@ def CheckCommitMessageBugEntry(input_api, output_api):
(prefix_guess, bug))
except ValueError:
results.append(bogus_bug_msg % bug)
elif not re.match(r'\w+:\d+', bug):
elif not (re.match(r'\w+:\d+', bug) or re.match(r'b/\d+', bug)):
results.append(bogus_bug_msg % bug)
return [output_api.PresubmitError(r) for r in results]

View file

@ -47,6 +47,18 @@ class CheckBugEntryFieldTest(unittest.TestCase):
mock_output_api)
self.assertEqual(0, len(errors))
def testCommitMessageBugEntrySupportInternalBugReference(self):
mock_input_api = MockInputApi()
mock_output_api = MockOutputApi()
mock_input_api.change.BUG = 'b/12345'
errors = PRESUBMIT.CheckCommitMessageBugEntry(mock_input_api,
mock_output_api)
self.assertEqual(0, len(errors))
mock_input_api.change.BUG = 'b/12345, webrtc:1234'
errors = PRESUBMIT.CheckCommitMessageBugEntry(mock_input_api,
mock_output_api)
self.assertEqual(0, len(errors))
class CheckNewlineAtTheEndOfProtoFilesTest(unittest.TestCase):