Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 pending_builds_len = len(builder.get('pending_builds', [])) | 617 pending_builds_len = len(builder.get('pending_builds', [])) |
| 618 if pending_builds_len > max_pendings: | 618 if pending_builds_len > max_pendings: |
| 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 | |
| 628 | |
| 629 def CheckOwners(input_api, output_api): | |
| 630 affected_files = set(input_api.change.AffectedFiles()) | |
| 631 owners_db = input_api.owners_db | |
| 632 | |
| 633 if input_api.is_commiting: | |
| 634 approving_reviewers = _GetApproversFor(input_api) | |
| 635 missing_files = owners_db.FilesNotCoveredBy(affected_files, | |
| 636 approving_reviewers): | |
| 637 if missing_files: | |
| 638 return [output_api.PresubmitPromptWarning('Missing approvals for: %s' % | |
| 639 ','.join(missing_files)] | |
| 640 return [] | |
| 641 else: | |
| 642 suggested_reviewers = owners_db.OwnersFor(affected_files)[0] | |
| 643 _AddReviewers(suggested_reviewers) | |
| 644 | |
| 645 def _GetApproversFor(input_api) | |
| 646 # TODO: implement - copy from the lgtm verifier, add support for | |
| 647 # "defer to". | |
| 648 return ['maruel'] | |
|
M-A Ruel
2011/02/24 16:25:57
I know it's an example but it should use fully qua
| |
| 649 | |
| 650 def _AddReviewers(input_api): | |
|
M-A Ruel
2011/02/24 16:25:57
This will need to be in presubmit_support.Change.
| |
| 651 # TODO: implement? | |
| 652 pass | |
| OLD | NEW |