Add presubmit check requiring an associated bug
Design doc: http://doc/1UkgDD99myoytD5yZemO-gvFwEkTw7dxOUbYWWaaVy3U
Fixed: chromium:1147795
Change-Id: Ib59fb0b08e698b660de26097578754420cc62c48
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2532237
Reviewed-by: Tim van der Lippe <[email protected]>
Reviewed-by: Peter Marshall <[email protected]>
Commit-Queue: Sigurd Schneider <[email protected]>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index adc190a..aa349bf 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -99,6 +99,30 @@
return results
+def _CheckBugAssociation(input_api, output_api, is_committing):
+ results = [output_api.PresubmitNotifyResult('Bug Association Check:')]
+ bugs = input_api.change.BugsFromDescription()
+ message = (
+ "Each CL should be associated with a bug, use \'Bug:\' or \'Fixed:\' lines in\n"
+ "the footer of the commit description. If you explicitly don\'t want to\n"
+ "set a bug, use \'Bug: none\' in the footer of the commit description.\n\n"
+ "Note: The footer of the commit description is the last block of lines in\n"
+ "the commit description that doesn't contain empty lines. This means that\n"
+ "any \'Bug:\' or \'Fixed:\' lines that are eventually followed by an empty\n"
+ "line are not detected by this presubmit check.")
+
+ if not bugs:
+ if is_committing:
+ results.append(output_api.PresubmitError(message))
+ else:
+ results.append(output_api.PresubmitNotifyResult(message))
+
+ for bug in bugs:
+ results.append(output_api.PresubmitNotifyResult(('%s') % bug))
+
+ return results
+
+
def _CheckBuildGN(input_api, output_api):
results = [output_api.PresubmitNotifyResult('Running BUILD.GN check:')]
script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts', 'check_gn.js')
@@ -476,6 +500,7 @@
results.extend(_CollectStrings(input_api, output_api))
# Run checks that rely on output from other DevTool checks
results.extend(_SideEffectChecks(input_api, output_api))
+ results.extend(_CheckBugAssociation(input_api, output_api, False))
return results
@@ -488,6 +513,7 @@
# Run checks that rely on output from other DevTool checks
results.extend(_SideEffectChecks(input_api, output_api))
results.extend(input_api.canned_checks.CheckChangeHasDescription(input_api, output_api))
+ results.extend(_CheckBugAssociation(input_api, output_api, True))
return results