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 | 7 |
8 ### Description checks | 8 ### Description checks |
9 | 9 |
10 def CheckChangeHasTestField(input_api, output_api): | 10 def CheckChangeHasTestField(input_api, output_api): |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 if text.strip() == '': | 59 if text.strip() == '': |
60 if input_api.is_committing: | 60 if input_api.is_committing: |
61 return [output_api.PresubmitError('Add a description.')] | 61 return [output_api.PresubmitError('Add a description.')] |
62 else: | 62 else: |
63 return [output_api.PresubmitNotifyResult('Add a description.')] | 63 return [output_api.PresubmitNotifyResult('Add a description.')] |
64 return [] | 64 return [] |
65 | 65 |
66 | 66 |
67 def CheckChangeWasUploaded(input_api, output_api): | 67 def CheckChangeWasUploaded(input_api, output_api): |
68 """Checks that the issue was uploaded before committing.""" | 68 """Checks that the issue was uploaded before committing.""" |
69 if (input_api.is_committing and | 69 if input_api.is_committing and not input_api.change.issue: |
70 (not input_api.change.issue or not input_api.change.patchset)): | |
71 return [output_api.PresubmitError( | 70 return [output_api.PresubmitError( |
72 'Issue wasn\'t uploaded. Please upload first.')] | 71 'Issue wasn\'t uploaded. Please upload first.')] |
73 return [] | 72 return [] |
74 | 73 |
75 | 74 |
76 ### Content checks | 75 ### Content checks |
77 | 76 |
78 def CheckDoNotSubmitInFiles(input_api, output_api): | 77 def CheckDoNotSubmitInFiles(input_api, output_api): |
79 """Checks that the user didn't add 'DO NOT ' + 'SUBMIT' to any files.""" | 78 """Checks that the user didn't add 'DO NOT ' + 'SUBMIT' to any files.""" |
80 # We want to check every text file, not just source files. | 79 # We want to check every text file, not just source files. |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 936 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
938 input_api, output_api)) | 937 input_api, output_api)) |
939 snapshot("checking license") | 938 snapshot("checking license") |
940 results.extend(input_api.canned_checks.CheckLicense( | 939 results.extend(input_api.canned_checks.CheckLicense( |
941 input_api, output_api, license_header, source_file_filter=sources)) | 940 input_api, output_api, license_header, source_file_filter=sources)) |
942 snapshot("checking was uploaded") | 941 snapshot("checking was uploaded") |
943 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | 942 results.extend(input_api.canned_checks.CheckChangeWasUploaded( |
944 input_api, output_api)) | 943 input_api, output_api)) |
945 snapshot("done") | 944 snapshot("done") |
946 return results | 945 return results |
OLD | NEW |