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

Side by Side Diff: presubmit_canned_checks.py

Issue 6674014: Make git-cl work with OWNERS files in a non .git/hooks/pre-cl-* world (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase to HEAD, minor linting, cleanup, testing, fix post-commit hook Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 ### Description checks 7 ### Description checks
8 8
9 def CheckChangeHasTestField(input_api, output_api): 9 def CheckChangeHasTestField(input_api, output_api):
10 """Requires that the changelist have a TEST= field.""" 10 """Requires that the changelist have a TEST= field."""
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 out.append('%s has %d build(s) pending' % 619 out.append('%s has %d build(s) pending' %
620 (builder_name, pending_builds_len)) 620 (builder_name, pending_builds_len))
621 if out: 621 if out:
622 return [output_api.PresubmitPromptWarning( 622 return [output_api.PresubmitPromptWarning(
623 'Build(s) pending. It is suggested to wait that no more than %d ' 623 'Build(s) pending. It is suggested to wait that no more than %d '
624 'builds are pending.' % max_pendings, 624 'builds are pending.' % max_pendings,
625 long_text='\n'.join(out))] 625 long_text='\n'.join(out))]
626 return [] 626 return []
627 627
628 628
629 def CheckOwners(input_api, output_api, source_file_filter=None): 629 def CheckOwners(input_api, output_api, email_regexp=None,
630 source_file_filter=None):
630 affected_files = set([f.LocalPath() for f in 631 affected_files = set([f.LocalPath() for f in
631 input_api.change.AffectedFiles(source_file_filter)]) 632 input_api.change.AffectedFiles(source_file_filter)])
632 owners_db = input_api.owners_db 633 owners_db = input_api.owners_db
634 if email_regexp:
635 owners_db.email_regexp = input_api.re.compile(email_regexp)
633 636
634 if input_api.is_committing and input_api.tbr: 637 if input_api.is_committing and input_api.tbr:
635 return [output_api.PresubmitNotifyResult( 638 return [output_api.PresubmitNotifyResult(
636 '--tbr was specified, skipping OWNERS check')] 639 '--tbr was specified, skipping OWNERS check')]
637 elif input_api.is_committing: 640 elif input_api.is_committing:
638 approvers = _Approvers(input_api, owners_db.email_regexp) 641 approvers = _Approvers(input_api, owners_db.email_regexp)
639 missing_files = owners_db.files_not_covered_by(affected_files, approvers) 642 missing_files = owners_db.files_not_covered_by(affected_files, approvers)
640 if missing_files: 643 if missing_files:
641 return [output_api.PresubmitError('Missing LGTM from an OWNER for: %s' % 644 return [output_api.PresubmitError('Missing LGTM from an OWNER for: %s' %
642 ','.join(missing_files))] 645 ','.join(missing_files))]
(...skipping 22 matching lines...) Expand all
665 # redundant (since the commit queue also enforces the presubmit checks). 668 # redundant (since the commit queue also enforces the presubmit checks).
666 def match_reviewer(r): 669 def match_reviewer(r):
667 return email_regexp.match(r) and not input_api.re.match(owner, r) 670 return email_regexp.match(r) and not input_api.re.match(owner, r)
668 671
669 approvers = [] 672 approvers = []
670 for m in issue_props['messages']: 673 for m in issue_props['messages']:
671 if 'lgtm' in m['text'].lower() and match_reviewer(m['sender']): 674 if 'lgtm' in m['text'].lower() and match_reviewer(m['sender']):
672 approvers.append(m['sender']) 675 approvers.append(m['sender'])
673 return set(approvers) 676 return set(approvers)
674 677
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698