From 81a58c7d816baf40aeecf626e5be5e1f0d03a097 Mon Sep 17 00:00:00 2001 From: charujain Date: Mon, 25 Sep 2017 13:25:45 +0200 Subject: [PATCH] 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 Reviewed-by: Henrik Kjellander Cr-Commit-Position: refs/heads/master@{#19972} --- PRESUBMIT.py | 4 ++-- presubmit_test.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 70c4759d13..df891a6c3e 100755 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -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] diff --git a/presubmit_test.py b/presubmit_test.py index c9ee80b17c..5c653d69fd 100755 --- a/presubmit_test.py +++ b/presubmit_test.py @@ -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):