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

Side by Side Diff: PRESUBMIT.py

Issue 3010153002: PRESUBMIT: Enforce tracker prefix for all BUG entries (Closed)
Patch Set: Added in test directory 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 unified diff | Download patch
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | PRESUBMIT_test.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license 3 # Use of this source code is governed by a BSD-style license
4 # that can be found in the LICENSE file in the root of the source 4 # that can be found in the LICENSE file in the root of the source
5 # tree. An additional intellectual property rights grant can be found 5 # tree. An additional intellectual property rights grant can be found
6 # in the file PATENTS. All contributing project authors may 6 # in the file PATENTS. All contributing project authors may
7 # be found in the AUTHORS file in the root of the source tree. 7 # be found in the AUTHORS file in the root of the source tree.
8 8
9 import json 9 import json
10 import os 10 import os
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if warning_descriptions: 416 if warning_descriptions:
417 results.append(output_api.PresubmitPromptOrNotify( 417 results.append(output_api.PresubmitPromptOrNotify(
418 'You added one or more #includes of files that are temporarily\n' 418 'You added one or more #includes of files that are temporarily\n'
419 'allowed but being removed. Can you avoid introducing the\n' 419 'allowed but being removed. Can you avoid introducing the\n'
420 '#include? See relevant DEPS file(s) for details and contacts.\n' 420 '#include? See relevant DEPS file(s) for details and contacts.\n'
421 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for ' 421 'See https://cs.chromium.org/chromium/src/buildtools/checkdeps/ for '
422 'more details about checkdeps.', 422 'more details about checkdeps.',
423 warning_descriptions)) 423 warning_descriptions))
424 return results 424 return results
425 425
426 def _CheckCommitMessageBugEntry(input_api, output_api):
427 """Check that bug entries are well-formed in commit message."""
428 bogus_bug_msg = (
429 'Bogus BUG entry: %s. Please specify the issue tracker prefix and the '
430 'issue number, separated by a colon, e.g. webrtc:123 or chromium:12345.')
431 results = []
432 for bug in (input_api.change.BUG or '').split(','):
433 bug = bug.strip()
434 if bug.lower() == 'none':
435 continue
436 if ':' not in bug:
437 try:
438 if int(bug) > 100000:
439 # Rough indicator for current chromium bugs.
440 prefix_guess = 'chromium'
441 else:
442 prefix_guess = 'webrtc'
443 results.append('BUG entry requires issue tracker prefix, e.g. %s:%s' %
444 (prefix_guess, bug))
445 except ValueError:
446 results.append(bogus_bug_msg % bug)
447 elif not re.match(r'\w+:\d+', bug):
448 results.append(bogus_bug_msg % bug)
449 return [output_api.PresubmitError(r) for r in results]
450
426 def _CheckChangeHasBugField(input_api, output_api): 451 def _CheckChangeHasBugField(input_api, output_api):
427 """Requires that the changelist have a BUG= field. 452 """Requires that the changelist have a BUG= field.
428 453
429 This check is stricter than the one in depot_tools/presubmit_canned_checks.py 454 This check is stricter than the one in depot_tools/presubmit_canned_checks.py
430 since it fails the presubmit if the BUG= field is missing or doesn't contain 455 since it fails the presubmit if the BUG= field is missing or doesn't contain
431 a bug reference. 456 a bug reference.
432 """ 457 """
433 if input_api.change.BUG: 458 if input_api.change.BUG:
434 return [] 459 return []
435 else: 460 else:
(...skipping 26 matching lines...) Expand all
462 results.append(output_api.PresubmitError('%s could not be parsed: %s' % 487 results.append(output_api.PresubmitError('%s could not be parsed: %s' %
463 (affected_file.LocalPath(), parse_error))) 488 (affected_file.LocalPath(), parse_error)))
464 return results 489 return results
465 490
466 491
467 def _RunPythonTests(input_api, output_api): 492 def _RunPythonTests(input_api, output_api):
468 def Join(*args): 493 def Join(*args):
469 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) 494 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
470 495
471 test_directories = [ 496 test_directories = [
497 '/',
472 Join('webrtc', 'rtc_tools', 'py_event_log_analyzer'), 498 Join('webrtc', 'rtc_tools', 'py_event_log_analyzer'),
473 Join('webrtc', 'rtc_tools'), 499 Join('webrtc', 'rtc_tools'),
474 Join('webrtc', 'audio', 'test', 'unittests'), 500 Join('webrtc', 'audio', 'test', 'unittests'),
475 ] + [ 501 ] + [
476 root for root, _, files in os.walk(Join('tools_webrtc')) 502 root for root, _, files in os.walk(Join('tools_webrtc'))
477 if any(f.endswith('_test.py') for f in files) 503 if any(f.endswith('_test.py') for f in files)
478 ] 504 ]
479 505
480 tests = [] 506 tests = []
481 for directory in test_directories: 507 for directory in test_directories:
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 def CheckChangeOnCommit(input_api, output_api): 616 def CheckChangeOnCommit(input_api, output_api):
591 results = [] 617 results = []
592 results.extend(_CommonChecks(input_api, output_api)) 618 results.extend(_CommonChecks(input_api, output_api))
593 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api)) 619 results.extend(_VerifyNativeApiHeadersListIsValid(input_api, output_api))
594 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) 620 results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
595 results.extend(input_api.canned_checks.CheckChangeWasUploaded( 621 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
596 input_api, output_api)) 622 input_api, output_api))
597 results.extend(input_api.canned_checks.CheckChangeHasDescription( 623 results.extend(input_api.canned_checks.CheckChangeHasDescription(
598 input_api, output_api)) 624 input_api, output_api))
599 results.extend(_CheckChangeHasBugField(input_api, output_api)) 625 results.extend(_CheckChangeHasBugField(input_api, output_api))
626 results.extend(_CheckCommitMessageBugEntry(input_api, output_api))
600 results.extend(input_api.canned_checks.CheckTreeIsOpen( 627 results.extend(input_api.canned_checks.CheckTreeIsOpen(
601 input_api, output_api, 628 input_api, output_api,
602 json_url='http://webrtc-status.appspot.com/current?format=json')) 629 json_url='http://webrtc-status.appspot.com/current?format=json'))
603 return results 630 return results
604 631
605 632
606 def _CheckOrphanHeaders(input_api, output_api): 633 def _CheckOrphanHeaders(input_api, output_api):
607 # We need to wait until we have an input_api object and use this 634 # We need to wait until we have an input_api object and use this
608 # roundabout construct to import prebubmit_checks_lib because this file is 635 # roundabout construct to import prebubmit_checks_lib because this file is
609 # eval-ed and thus doesn't have __file__. 636 # eval-ed and thus doesn't have __file__.
(...skipping 29 matching lines...) Expand all
639 results = [] 666 results = []
640 source_file_filter = lambda x: input_api.FilterSourceFile( 667 source_file_filter = lambda x: input_api.FilterSourceFile(
641 x, white_list=(r'.+\.proto$',)) 668 x, white_list=(r'.+\.proto$',))
642 for f in input_api.AffectedSourceFiles(source_file_filter): 669 for f in input_api.AffectedSourceFiles(source_file_filter):
643 file_path = f.LocalPath() 670 file_path = f.LocalPath()
644 with open(file_path) as f: 671 with open(file_path) as f:
645 lines = f.readlines() 672 lines = f.readlines()
646 if lines[-1] != '\n' or lines[-2] == '\n': 673 if lines[-1] != '\n' or lines[-2] == '\n':
647 results.append(output_api.PresubmitError(error_msg.format(file_path))) 674 results.append(output_api.PresubmitError(error_msg.format(file_path)))
648 return results 675 return results
OLDNEW
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | PRESUBMIT_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698