OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 import os as _os | 7 import os as _os |
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) | 8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) |
9 | 9 |
10 | 10 |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
845 | 845 |
846 | 846 |
847 def _GetRietveldIssueProps(input_api, messages): | 847 def _GetRietveldIssueProps(input_api, messages): |
848 """Gets the issue properties from rietveld.""" | 848 """Gets the issue properties from rietveld.""" |
849 issue = input_api.change.issue | 849 issue = input_api.change.issue |
850 if issue and input_api.rietveld: | 850 if issue and input_api.rietveld: |
851 return input_api.rietveld.get_issue_properties( | 851 return input_api.rietveld.get_issue_properties( |
852 issue=int(issue), messages=messages) | 852 issue=int(issue), messages=messages) |
853 | 853 |
854 | 854 |
855 def _EnsureEmailFormat(reviewer): | |
856 """Converts |reviewer| into an email address if it is not one already.""" | |
857 if '@' in reviewer: | |
858 return reviewer | |
859 return reviewer + '@chromium.org' | |
860 | |
861 | |
855 def _ReviewersFromChange(change): | 862 def _ReviewersFromChange(change): |
856 """Return the reviewers specified in the |change|, if any.""" | 863 """Return the reviewers specified in the |change|, if any.""" |
857 reviewers = set() | 864 reviewers = set() |
858 if change.R: | 865 if change.R: |
859 reviewers.update(set([r.strip() for r in change.R.split(',')])) | 866 reviewers.update(set([r.strip() for r in change.R.split(',')])) |
860 if change.TBR: | 867 if change.TBR: |
861 reviewers.update(set([r.strip() for r in change.TBR.split(',')])) | 868 reviewers.update(set([r.strip() for r in change.TBR.split(',')])) |
862 return reviewers | 869 return set([_EnsureEmailFormat(reviewer) for reviewer in reviewers]) |
M-A Ruel
2014/03/28 00:19:35
FTR;
return set(_EnsureEmailFormat(reviewer) for r
Ilya Sherman
2014/04/09 01:34:59
Done.
| |
863 | 870 |
864 | 871 |
865 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): | 872 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): |
866 """Return the owner and reviewers of a change, if any. | 873 """Return the owner and reviewers of a change, if any. |
867 | 874 |
868 If approval_needed is True, only reviewers who have approved the change | 875 If approval_needed is True, only reviewers who have approved the change |
869 will be returned. | 876 will be returned. |
870 """ | 877 """ |
871 issue_props = _GetRietveldIssueProps(input_api, True) | 878 issue_props = _GetRietveldIssueProps(input_api, True) |
872 if not issue_props: | 879 if not issue_props: |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1059 def CheckPatchFormatted(input_api, output_api): | 1066 def CheckPatchFormatted(input_api, output_api): |
1060 import git_cl | 1067 import git_cl |
1061 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] | 1068 cmd = ['cl', 'format', '--dry-run', input_api.PresubmitLocalPath()] |
1062 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) | 1069 code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=True) |
1063 if code == 2: | 1070 if code == 2: |
1064 return [output_api.PresubmitPromptWarning( | 1071 return [output_api.PresubmitPromptWarning( |
1065 'Your patch is not formatted, please run git cl format.')] | 1072 'Your patch is not formatted, please run git cl format.')] |
1066 # As this is just a warning, ignore all other errors if the user | 1073 # As this is just a warning, ignore all other errors if the user |
1067 # happens to have a broken clang-format, doesn't use git, etc etc. | 1074 # happens to have a broken clang-format, doesn't use git, etc etc. |
1068 return [] | 1075 return [] |
OLD | NEW |