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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 return [] | 648 return [] |
| 649 | 649 |
| 650 suggested_reviewers = owners_db.reviewers_for(affected_files) | 650 suggested_reviewers = owners_db.reviewers_for(affected_files) |
| 651 return [output_api.PresubmitAddReviewers(suggested_reviewers)] | 651 return [output_api.PresubmitAddReviewers(suggested_reviewers)] |
| 652 | 652 |
| 653 | 653 |
| 654 def _Approvers(input_api, email_regexp): | 654 def _Approvers(input_api, email_regexp): |
| 655 if not input_api.change.issue: | 655 if not input_api.change.issue: |
| 656 return [] | 656 return [] |
| 657 | 657 |
| 658 path = '/api/%s?messages=true' | 658 # TODO(dpranke): Should figure out if input_api.host_url is supposed to |
|
M-A Ruel
2011/03/17 19:12:54
There's also the problem that some issues needs to
| |
| 659 url = (input_api.host_url + path) % input_api.change.issue | 659 # be a host or a scheme+host and normalize it there. |
| 660 host = input_api.host_url | |
| 661 if not host.startswith('http://'): | |
|
M-A Ruel
2011/03/17 19:43:34
Some host are https:// only, please take that in a
| |
| 662 host = 'http://' + host | |
| 663 url = '%s/api/%s?messages=true' % (host, input_api.change.issue) | |
| 660 | 664 |
| 661 f = input_api.urllib2.urlopen(url) | 665 f = input_api.urllib2.urlopen(url) |
| 662 issue_props = input_api.json.load(f) | 666 issue_props = input_api.json.load(f) |
| 663 owner = input_api.re.escape(issue_props['owner']) | 667 owner = input_api.re.escape(issue_props['owner']) |
| 664 | 668 |
| 665 # TODO(dpranke): This mimics the logic in | 669 # TODO(dpranke): This mimics the logic in |
| 666 # /tools/commit-queue/verifiers/reviewer_lgtm.py | 670 # /tools/commit-queue/verifiers/reviewer_lgtm.py |
| 667 # We should share the code and/or remove the check there where it is | 671 # We should share the code and/or remove the check there where it is |
| 668 # redundant (since the commit queue also enforces the presubmit checks). | 672 # redundant (since the commit queue also enforces the presubmit checks). |
| 669 def match_reviewer(r): | 673 def match_reviewer(r): |
| 670 return email_regexp.match(r) and not input_api.re.match(owner, r) | 674 return email_regexp.match(r) and not input_api.re.match(owner, r) |
| 671 | 675 |
| 672 approvers = [] | 676 approvers = [] |
| 673 for m in issue_props.get('messages', []): | 677 for m in issue_props.get('messages', []): |
| 674 if 'lgtm' in m['text'].lower() and match_reviewer(m['sender']): | 678 if 'lgtm' in m['text'].lower() and match_reviewer(m['sender']): |
| 675 approvers.append(m['sender']) | 679 approvers.append(m['sender']) |
| 676 return set(approvers) | 680 return set(approvers) |
| 677 | 681 |
| OLD | NEW |