maruel@chromium.org | 3d23524 | 2009-05-15 12:40:48 +0000 | [diff] [blame] | 1 | # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Top-level presubmit script for depot tools. |
| 6 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 | details on the presubmit API built into gcl. |
| 9 | """ |
| 10 | |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 11 | UNIT_TESTS = [ |
| 12 | 'tests.gcl_unittest', |
maruel@chromium.org | ad80e3b | 2010-09-09 14:18:28 +0000 | [diff] [blame] | 13 | 'tests.gclient_scm_test', |
maruel@chromium.org | 888b835 | 2010-08-11 18:42:03 +0000 | [diff] [blame] | 14 | 'tests.gclient_smoketest', |
maruel@chromium.org | d5800f1 | 2009-11-12 20:03:43 +0000 | [diff] [blame] | 15 | 'tests.gclient_utils_test', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 16 | 'tests.presubmit_unittest', |
maruel@chromium.org | d5800f1 | 2009-11-12 20:03:43 +0000 | [diff] [blame] | 17 | 'tests.scm_unittest', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 18 | 'tests.trychange_unittest', |
nirnimesh@chromium.org | b82e409 | 2009-06-18 14:24:08 +0000 | [diff] [blame] | 19 | 'tests.watchlists_unittest', |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 20 | ] |
maruel@chromium.org | 3d23524 | 2009-05-15 12:40:48 +0000 | [diff] [blame] | 21 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 22 | def CommonChecks(input_api, output_api): |
maruel@chromium.org | 7b305e8 | 2009-05-19 18:24:20 +0000 | [diff] [blame] | 23 | output = [] |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 24 | output.extend(input_api.canned_checks.RunPythonUnitTests( |
| 25 | input_api, |
| 26 | output_api, |
| 27 | UNIT_TESTS)) |
maruel@chromium.org | bbfc80f | 2010-06-22 17:55:15 +0000 | [diff] [blame] | 28 | output.extend(WasGitClUploadHookModified(input_api, output_api)) |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 29 | |
maruel@chromium.org | bf38a7e | 2010-12-14 18:15:54 +0000 | [diff] [blame] | 30 | white_list = [r'.*\.py$', r'.*git-try$'] |
| 31 | black_list = list(input_api.DEFAULT_BLACK_LIST) + [ |
| 32 | r'.*cpplint\.py$', r'.*git_cl_repo.*'] |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 33 | output.extend(input_api.canned_checks.RunPylint( |
| 34 | input_api, |
| 35 | output_api, |
maruel@chromium.org | bf38a7e | 2010-12-14 18:15:54 +0000 | [diff] [blame] | 36 | white_list=white_list, |
| 37 | black_list=black_list)) |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 38 | return output |
| 39 | |
| 40 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 41 | def CheckChangeOnUpload(input_api, output_api): |
| 42 | return CommonChecks(input_api, output_api) |
| 43 | |
| 44 | |
maruel@chromium.org | ce30ef7 | 2009-05-25 15:20:42 +0000 | [diff] [blame] | 45 | def CheckChangeOnCommit(input_api, output_api): |
| 46 | output = [] |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 47 | output.extend(CommonChecks(input_api, output_api)) |
| 48 | output.extend(input_api.canned_checks.CheckDoNotSubmit( |
| 49 | input_api, |
| 50 | output_api)) |
maruel@chromium.org | 7b305e8 | 2009-05-19 18:24:20 +0000 | [diff] [blame] | 51 | return output |
maruel@chromium.org | bbfc80f | 2010-06-22 17:55:15 +0000 | [diff] [blame] | 52 | |
maruel@chromium.org | e94aedc | 2010-12-13 21:11:30 +0000 | [diff] [blame] | 53 | |
maruel@chromium.org | bbfc80f | 2010-06-22 17:55:15 +0000 | [diff] [blame] | 54 | def WasGitClUploadHookModified(input_api, output_api): |
| 55 | for affected_file in input_api.AffectedSourceFiles(None): |
| 56 | if (input_api.os_path.basename(affected_file.LocalPath()) == |
| 57 | 'git-cl-upload-hook'): |
| 58 | return [output_api.PresubmitPromptWarning( |
| 59 | 'Don\'t forget to fix git-cl to download the newest version of ' |
| 60 | 'git-cl-upload-hook')] |
| 61 | return [] |