| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Generic presubmit checks that can be reused by other presubmit checks.""" | 6 """Generic presubmit checks that can be reused by other presubmit checks.""" |
| 7 | 7 |
| 8 | 8 |
| 9 ### Description checks | 9 ### Description checks |
| 10 | 10 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 return [output_api.PresubmitPromptWarning(msg, items=bad)] | 171 return [output_api.PresubmitPromptWarning(msg, items=bad)] |
| 172 else: | 172 else: |
| 173 return [] | 173 return [] |
| 174 | 174 |
| 175 | 175 |
| 176 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): | 176 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): |
| 177 """Checks that the source files have svn:eol-style=LF.""" | 177 """Checks that the source files have svn:eol-style=LF.""" |
| 178 bad = filter(lambda f: f.scm == 'svn' and f.Property('svn:eol-style') != 'LF', | 178 bad = filter(lambda f: f.scm == 'svn' and f.Property('svn:eol-style') != 'LF', |
| 179 input_api.AffectedSourceFiles(source_file_filter)) | 179 input_api.AffectedSourceFiles(source_file_filter)) |
| 180 if bad: | 180 if bad: |
| 181 return [output_api.PresubmitError( | 181 if input_api.is_committing: |
| 182 "Fix these files with svn svn:eol-style=LF", items=bad)] | 182 return [output_api.PresubmitError( |
| 183 "Fix these files with svn svn:eol-style=LF", items=bad)] |
| 184 else: |
| 185 return [output_api.PresubmitNotifyResult( |
| 186 "Fix these files with svn svn:eol-style=LF", items=bad)] |
| 183 return [] | 187 return [] |
| 184 | 188 |
| 185 | 189 |
| 186 ### Other checks | 190 ### Other checks |
| 187 | 191 |
| 188 def CheckDoNotSubmit(input_api, output_api): | 192 def CheckDoNotSubmit(input_api, output_api): |
| 189 return ( | 193 return ( |
| 190 CheckDoNotSubmitInDescription(input_api, output_api) + | 194 CheckDoNotSubmitInDescription(input_api, output_api) + |
| 191 CheckDoNotSubmitInFiles(input_api, output_api) | 195 CheckDoNotSubmitInFiles(input_api, output_api) |
| 192 ) | 196 ) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 long_text=input_api.traceback.format_exc())) | 238 long_text=input_api.traceback.format_exc())) |
| 235 | 239 |
| 236 buffer = input_api.cStringIO.StringIO() | 240 buffer = input_api.cStringIO.StringIO() |
| 237 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run( | 241 results = input_api.unittest.TextTestRunner(stream=buffer, verbosity=0).run( |
| 238 input_api.unittest.TestSuite(tests_suite)) | 242 input_api.unittest.TestSuite(tests_suite)) |
| 239 if not results.wasSuccessful(): | 243 if not results.wasSuccessful(): |
| 240 outputs.append(message_type("%d unit tests failed." % | 244 outputs.append(message_type("%d unit tests failed." % |
| 241 (len(results.failures) + len(results.errors)), | 245 (len(results.failures) + len(results.errors)), |
| 242 long_text=buffer.getvalue())) | 246 long_text=buffer.getvalue())) |
| 243 return outputs | 247 return outputs |
| OLD | NEW |