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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 def CheckChangeHasDescription(input_api, output_api): | 56 def CheckChangeHasDescription(input_api, output_api): |
57 """Checks the CL description is not empty.""" | 57 """Checks the CL description is not empty.""" |
58 text = input_api.change.DescriptionText() | 58 text = input_api.change.DescriptionText() |
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 | |
67 def CheckChangeWasUploaded(input_api, output_api): | |
68 """Checks that the issue was uploaded before committing.""" | |
Nico
2011/07/24 19:59:33
This warns if I patch in someone else's patch with
| |
69 if (input_api.is_committing and | |
70 (not input_api.change.issue or not input_api.change.patchset)): | |
71 return [output_api.PresubmitError( | |
72 'Issue wasn\'t uploaded. Please upload first.')] | |
73 return [] | |
74 | |
75 | |
66 ### Content checks | 76 ### Content checks |
67 | 77 |
68 def CheckDoNotSubmitInFiles(input_api, output_api): | 78 def CheckDoNotSubmitInFiles(input_api, output_api): |
69 """Checks that the user didn't add 'DO NOT ' + 'SUBMIT' to any files.""" | 79 """Checks that the user didn't add 'DO NOT ' + 'SUBMIT' to any files.""" |
70 # We want to check every text file, not just source files. | 80 # We want to check every text file, not just source files. |
71 file_filter = lambda x : x | 81 file_filter = lambda x : x |
72 keyword = 'DO NOT ' + 'SUBMIT' | 82 keyword = 'DO NOT ' + 'SUBMIT' |
73 errors = _FindNewViolationsOfRule(lambda line : keyword not in line, | 83 errors = _FindNewViolationsOfRule(lambda line : keyword not in line, |
74 input_api, file_filter) | 84 input_api, file_filter) |
75 text = '\n'.join('Found %s in %s' % (keyword, loc) for loc in errors) | 85 text = '\n'.join('Found %s in %s' % (keyword, loc) for loc in errors) |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 if input_api.is_committing: | 932 if input_api.is_committing: |
923 snapshot("checking eol style") | 933 snapshot("checking eol style") |
924 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( | 934 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle( |
925 input_api, output_api, source_file_filter=text_files)) | 935 input_api, output_api, source_file_filter=text_files)) |
926 snapshot("checking svn mime types") | 936 snapshot("checking svn mime types") |
927 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( | 937 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( |
928 input_api, output_api)) | 938 input_api, output_api)) |
929 snapshot("checking license") | 939 snapshot("checking license") |
930 results.extend(input_api.canned_checks.CheckLicense( | 940 results.extend(input_api.canned_checks.CheckLicense( |
931 input_api, output_api, license_header, source_file_filter=sources)) | 941 input_api, output_api, license_header, source_file_filter=sources)) |
942 snapshot("checking was uploaded") | |
943 results.extend(input_api.canned_checks.CheckChangeWasUploaded( | |
944 input_api, output_api)) | |
932 snapshot("done") | 945 snapshot("done") |
933 return results | 946 return results |
OLD | NEW |