Commit 48c94753 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

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/+/3016587Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
parent 1606c25b
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment