Add presubmit notice if buganizer bug is malformed

If user enters buganizer bug prefixed with b/, warn user that b: is
expected.

R=apolito@google.com

Bug: 1226474
Change-Id: Ifbced843f9eecc00560cc273ae06bff9d435a815
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3016587
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
changes/87/3016587/3
Josip Sokcevic 4 years ago committed by LUCI CQ
parent 1606c25b44
commit 48c947534d

@ -50,7 +50,13 @@ OFF_UNLESS_MANUALLY_ENABLED_LINT_FILTERS = [
def CheckChangeHasBugField(input_api, output_api):
"""Requires that the changelist have a Bug: field."""
if input_api.change.BugsFromDescription():
bugs = input_api.change.BugsFromDescription()
if bugs:
if any(b.startswith('b/') for b in bugs):
return [
output_api.PresubmitNotifyResult(
'Buganizer bugs should be prefixed with b:, not b/.')
]
return []
else:
return [output_api.PresubmitNotifyResult(

@ -1993,9 +1993,13 @@ class CannedChecksUnittest(PresubmitTestsBase):
def testCannedCheckChangeHasBugField(self):
self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField,
'Foo\nBUG=1234', 'Foo\n',
presubmit.OutputApi.PresubmitNotifyResult,
False)
'Foo\nBUG=b:1234', 'Foo\n',
presubmit.OutputApi.PresubmitNotifyResult, False)
def testCannedCheckChangeHasBugFieldWithBuganizerSlash(self):
self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField,
'Foo\nBUG=b:1234', 'Foo\nBUG=b/1234',
presubmit.OutputApi.PresubmitNotifyResult, False)
def testCannedCheckChangeHasNoUnwantedTags(self):
self.DescriptionTest(presubmit_canned_checks.CheckChangeHasNoUnwantedTags,

Loading…
Cancel
Save