Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: PRESUBMIT.py

Issue 3010153002: PRESUBMIT: Enforce tracker prefix for all BUG entries (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 9a76412e0c57c04276b54ff8ca5a055a9c33adf2..3dba47de6167d68e29da786f453f723ab1a98a5e 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -423,6 +423,31 @@ def _CheckUnwantedDependencies(input_api, output_api):
warning_descriptions))
return results
+def _CheckCommitMessageBugEntry(input_api, output_api):
+ """Check that bug entries are well-formed in commit message."""
+ bogus_bug_msg = (
+ 'Bogus BUG entry: %s. Please specify the issue tracker prefix and the '
+ 'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.')
+ results = []
+ for bug in (input_api.change.BUG or '').split(','):
+ bug = bug.strip()
+ if 'none'.startswith(bug.lower()):
ehmaldonado_webrtc 2017/09/05 11:43:04 Why not bug.lower() == 'none'?
kjellander_webrtc 2017/09/05 14:37:53 Good point. It's copy-pasted from https://chromium
+ continue
+ if ':' not in bug:
+ try:
+ if int(bug) > 100000:
+ # Rough indicator for current chromium bugs.
+ prefix_guess = 'chromium'
+ else:
+ prefix_guess = 'webrtc'
+ results.append('BUG entry requires issue tracker prefix, e.g. %s:%s' %
+ (prefix_guess, bug))
+ except ValueError:
+ results.append(bogus_bug_msg % bug)
+ elif not re.match(r'\w+:\d+', bug):
+ results.append(bogus_bug_msg % bug)
+ return [output_api.PresubmitError(r) for r in results]
+
def _CheckChangeHasBugField(input_api, output_api):
"""Requires that the changelist have a BUG= field.
@@ -597,6 +622,7 @@ def CheckChangeOnCommit(input_api, output_api):
results.extend(input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
results.extend(_CheckChangeHasBugField(input_api, output_api))
+ results.extend(_CheckCommitMessageBugEntry(input_api, output_api))
results.extend(input_api.canned_checks.CheckTreeIsOpen(
input_api, output_api,
json_url='http://webrtc-status.appspot.com/current?format=json'))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698