Chromium Code Reviews| 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')) |