| OLD | NEW |
| 1 # Copyright 2012 The Swarming Authors. All rights reserved. | 1 # Copyright 2012 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 that | 2 # Use of this source code is governed by the Apache v2.0 license that can be |
| 3 # can be found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for swarm_client. | 5 """Top-level presubmit script for swarm_client. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 details on the presubmit API built into gcl. | 8 details on the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 def CommonChecks(input_api, output_api): | 11 def CommonChecks(input_api, output_api): |
| 12 import sys | 12 import sys |
| 13 def join(*args): | 13 def join(*args): |
| (...skipping 28 matching lines...) Expand all Loading... |
| 42 | 42 |
| 43 output.extend( | 43 output.extend( |
| 44 input_api.canned_checks.RunUnitTestsInDirectory( | 44 input_api.canned_checks.RunUnitTestsInDirectory( |
| 45 input_api, output_api, | 45 input_api, output_api, |
| 46 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests'), | 46 input_api.os_path.join(input_api.PresubmitLocalPath(), 'tests'), |
| 47 whitelist=[r'.+_test\.py$'], | 47 whitelist=[r'.+_test\.py$'], |
| 48 blacklist=blacklist)) | 48 blacklist=blacklist)) |
| 49 return output | 49 return output |
| 50 | 50 |
| 51 | 51 |
| 52 def header(input_api): | |
| 53 """Returns the expected license header regexp for this project.""" | |
| 54 current_year = int(input_api.time.strftime('%Y')) | |
| 55 allowed_years = (str(s) for s in reversed(xrange(2011, current_year + 1))) | |
| 56 years_re = '(' + '|'.join(allowed_years) + ')' | |
| 57 license_header = ( | |
| 58 r'.*? Copyright %(year)s The Swarming Authors\. ' | |
| 59 r'All rights reserved\.\n' | |
| 60 r'.*? Use of this source code is governed under the Apache License, ' | |
| 61 r'Version 2\.0 that\n' | |
| 62 r'.*? can be found in the LICENSE file\.(?: \*/)?\n' | |
| 63 ) % { | |
| 64 'year': years_re, | |
| 65 } | |
| 66 return license_header | |
| 67 | |
| 68 | |
| 69 def CheckChangeOnUpload(input_api, output_api): | 52 def CheckChangeOnUpload(input_api, output_api): |
| 70 return CommonChecks(input_api, output_api) | 53 return CommonChecks(input_api, output_api) |
| 71 | 54 |
| 72 | 55 |
| 73 def CheckChangeOnCommit(input_api, output_api): | 56 def CheckChangeOnCommit(input_api, output_api): |
| 74 output = CommonChecks(input_api, output_api) | 57 return CommonChecks(input_api, output_api) |
| 75 output.extend(input_api.canned_checks.PanProjectChecks( | |
| 76 input_api, output_api, | |
| 77 owners_check=False, | |
| 78 license_header=header(input_api))) | |
| 79 return output | |
| OLD | NEW |