| 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   789  |   789  | 
|   790   owners_db = input_api.owners_db |   790   owners_db = input_api.owners_db | 
|   791   owner_email, reviewers = _RietveldOwnerAndReviewers( |   791   owner_email, reviewers = _RietveldOwnerAndReviewers( | 
|   792       input_api, |   792       input_api, | 
|   793       owners_db.email_regexp, |   793       owners_db.email_regexp, | 
|   794       approval_needed=input_api.is_committing) |   794       approval_needed=input_api.is_committing) | 
|   795  |   795  | 
|   796   owner_email = owner_email or input_api.change.author_email |   796   owner_email = owner_email or input_api.change.author_email | 
|   797  |   797  | 
|   798   if author_counts_as_owner and owner_email: |   798   if author_counts_as_owner and owner_email: | 
|   799     reviewers_plus_owner = set([owner_email]).union(reviewers or set()) |   799     reviewers_plus_owner = set([owner_email]).union(reviewers) | 
|   800     missing_files = owners_db.files_not_covered_by(affected_files, |   800     missing_files = owners_db.files_not_covered_by(affected_files, | 
|   801         reviewers_plus_owner) |   801         reviewers_plus_owner) | 
|   802   else: |   802   else: | 
|   803     missing_files = owners_db.files_not_covered_by(affected_files, reviewers) |   803     missing_files = owners_db.files_not_covered_by(affected_files, reviewers) | 
|   804  |   804  | 
|   805   if missing_files: |   805   if missing_files: | 
|   806     output_list = [ |   806     output_list = [ | 
|   807         output('Missing %s for these files:\n    %s' % |   807         output('Missing %s for these files:\n    %s' % | 
|   808                (needed, '\n    '.join(missing_files)))] |   808                (needed, '\n    '.join(missing_files)))] | 
|   809     if not input_api.is_committing: |   809     if not input_api.is_committing: | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
|   826  |   826  | 
|   827  |   827  | 
|   828 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): |   828 def _RietveldOwnerAndReviewers(input_api, email_regexp, approval_needed=False): | 
|   829   """Return the owner and reviewers of a change, if any. |   829   """Return the owner and reviewers of a change, if any. | 
|   830  |   830  | 
|   831   If approval_needed is True, only reviewers who have approved the change |   831   If approval_needed is True, only reviewers who have approved the change | 
|   832   will be returned. |   832   will be returned. | 
|   833   """ |   833   """ | 
|   834   issue_props = _GetRietveldIssueProps(input_api, True) |   834   issue_props = _GetRietveldIssueProps(input_api, True) | 
|   835   if not issue_props: |   835   if not issue_props: | 
|   836     return None, None |   836     return None, set() | 
|   837  |   837  | 
|   838   if not approval_needed: |   838   if not approval_needed: | 
|   839     return issue_props['owner_email'], set(issue_props['reviewers']) |   839     return issue_props['owner_email'], set(issue_props['reviewers']) | 
|   840  |   840  | 
|   841   owner_email = issue_props['owner_email'] |   841   owner_email = issue_props['owner_email'] | 
|   842  |   842  | 
|   843   def match_reviewer(r): |   843   def match_reviewer(r): | 
|   844     return email_regexp.match(r) and r != owner_email |   844     return email_regexp.match(r) and r != owner_email | 
|   845  |   845  | 
|   846   messages = issue_props.get('messages', []) |   846   messages = issue_props.get('messages', []) | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1007     snapshot("checking description") |  1007     snapshot("checking description") | 
|  1008     results.extend(input_api.canned_checks.CheckChangeHasDescription( |  1008     results.extend(input_api.canned_checks.CheckChangeHasDescription( | 
|  1009         input_api, output_api)) |  1009         input_api, output_api)) | 
|  1010     results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( |  1010     results.extend(input_api.canned_checks.CheckDoNotSubmitInDescription( | 
|  1011         input_api, output_api)) |  1011         input_api, output_api)) | 
|  1012     snapshot("checking do not submit in files") |  1012     snapshot("checking do not submit in files") | 
|  1013     results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( |  1013     results.extend(input_api.canned_checks.CheckDoNotSubmitInFiles( | 
|  1014         input_api, output_api)) |  1014         input_api, output_api)) | 
|  1015   snapshot("done") |  1015   snapshot("done") | 
|  1016   return results |  1016   return results | 
| OLD | NEW |