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 """Top-level presubmit script for depot tools. | 5 """Top-level presubmit script for depot tools. |
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 UNIT_TESTS = [ | 11 UNIT_TESTS = [ |
12 'tests.gcl_unittest', | 12 'tests.gcl_unittest', |
13 'tests.gclient_scm_test', | 13 'tests.gclient_scm_test', |
14 'tests.gclient_smoketest', | 14 'tests.gclient_smoketest', |
15 'tests.gclient_utils_test', | 15 'tests.gclient_utils_test', |
16 'tests.presubmit_unittest', | 16 'tests.presubmit_unittest', |
17 'tests.scm_unittest', | 17 'tests.scm_unittest', |
18 'tests.trychange_unittest', | 18 'tests.trychange_unittest', |
19 'tests.watchlists_unittest', | 19 'tests.watchlists_unittest', |
20 ] | 20 ] |
21 | 21 |
22 def CommonChecks(input_api, output_api): | 22 def CommonChecks(input_api, output_api): |
23 output = [] | 23 output = [] |
| 24 # Verify that LocalPath() is local, e.g.: |
| 25 # os.path.join(PresubmitLocalPath(), LocalPath()) == AbsoluteLocalPath() |
| 26 for i in input_api.AffectedFiles(): |
| 27 if (input_api.os_path.join(input_api.PresubmitLocalPath(), i.LocalPath()) != |
| 28 i.AbsoluteLocalPath()): |
| 29 output.append(output_api.PresubmitError('Path inconsistency')) |
| 30 # Return right away because it needs to be fixed first. |
| 31 return output |
| 32 |
24 output.extend(input_api.canned_checks.RunPythonUnitTests( | 33 output.extend(input_api.canned_checks.RunPythonUnitTests( |
25 input_api, | 34 input_api, |
26 output_api, | 35 output_api, |
27 UNIT_TESTS)) | 36 UNIT_TESTS)) |
28 output.extend(WasGitClUploadHookModified(input_api, output_api)) | 37 output.extend(WasGitClUploadHookModified(input_api, output_api)) |
29 | 38 |
30 white_list = [r'.*\.py$', r'.*git-try$'] | 39 white_list = [r'.*\.py$', r'^git-try$'] |
31 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ | 40 black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
32 r'.*cpplint\.py$', r'.*git_cl\/.*'] | 41 r'^cpplint\.py$', |
| 42 r'^git_cl[\/\\].*', |
| 43 r'^git_cl_repo[\/\\].*', |
| 44 r'^git_cl[\/\\]test[\/\\]rietveld.*'] |
33 output.extend(input_api.canned_checks.RunPylint( | 45 output.extend(input_api.canned_checks.RunPylint( |
34 input_api, | 46 input_api, |
35 output_api, | 47 output_api, |
36 white_list=white_list, | 48 white_list=white_list, |
37 black_list=black_list)) | 49 black_list=black_list)) |
38 return output | 50 return output |
39 | 51 |
40 | 52 |
41 def CheckChangeOnUpload(input_api, output_api): | 53 def CheckChangeOnUpload(input_api, output_api): |
42 return CommonChecks(input_api, output_api) | 54 return CommonChecks(input_api, output_api) |
43 | 55 |
44 | 56 |
45 def CheckChangeOnCommit(input_api, output_api): | 57 def CheckChangeOnCommit(input_api, output_api): |
46 output = [] | 58 output = [] |
47 output.extend(CommonChecks(input_api, output_api)) | 59 output.extend(CommonChecks(input_api, output_api)) |
48 output.extend(input_api.canned_checks.CheckDoNotSubmit( | 60 output.extend(input_api.canned_checks.CheckDoNotSubmit( |
49 input_api, | 61 input_api, |
50 output_api)) | 62 output_api)) |
51 return output | 63 return output |
52 | 64 |
53 | 65 |
54 def WasGitClUploadHookModified(input_api, output_api): | 66 def WasGitClUploadHookModified(input_api, output_api): |
55 for affected_file in input_api.AffectedSourceFiles(None): | 67 for affected_file in input_api.AffectedSourceFiles(None): |
56 if (input_api.os_path.basename(affected_file.LocalPath()) == | 68 if (input_api.os_path.basename(affected_file.LocalPath()) == |
57 'git-cl-upload-hook'): | 69 'git-cl-upload-hook'): |
58 return [output_api.PresubmitPromptWarning( | 70 return [output_api.PresubmitPromptWarning( |
59 'Don\'t forget to fix git-cl to download the newest version of ' | 71 'Don\'t forget to fix git-cl to download the newest version of ' |
60 'git-cl-upload-hook')] | 72 'git-cl-upload-hook')] |
61 return [] | 73 return [] |
OLD | NEW |