[email protected] | 3d23524 | 2009-05-15 12:40:48 | [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 | |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 11 | UNIT_TESTS = [ |
| 12 | 'tests.gcl_unittest', |
[email protected] | e28e498 | 2009-09-25 20:51:45 | [diff] [blame] | 13 | 'tests.gclient_scm_test', |
[email protected] | d5800f1 | 2009-11-12 20:03:43 | [diff] [blame] | 14 | 'tests.gclient_utils_test', |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 15 | 'tests.presubmit_unittest', |
[email protected] | d5800f1 | 2009-11-12 20:03:43 | [diff] [blame] | 16 | 'tests.scm_unittest', |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 17 | 'tests.trychange_unittest', |
[email protected] | b82e409 | 2009-06-18 14:24:08 | [diff] [blame] | 18 | 'tests.watchlists_unittest', |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 19 | ] |
[email protected] | 3d23524 | 2009-05-15 12:40:48 | [diff] [blame] | 20 | |
| 21 | def CheckChangeOnUpload(input_api, output_api): |
[email protected] | 7b305e8 | 2009-05-19 18:24:20 | [diff] [blame] | 22 | output = [] |
| 23 | output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, |
| 24 | output_api, |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 25 | UNIT_TESTS)) |
[email protected] | bbfc80f | 2010-06-22 17:55:15 | [diff] [blame^] | 26 | output.extend(WasGitClUploadHookModified(input_api, output_api)) |
[email protected] | ce30ef7 | 2009-05-25 15:20:42 | [diff] [blame] | 27 | return output |
| 28 | |
| 29 | |
| 30 | def CheckChangeOnCommit(input_api, output_api): |
| 31 | output = [] |
| 32 | output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, |
| 33 | output_api, |
| 34 | UNIT_TESTS)) |
[email protected] | 7b305e8 | 2009-05-19 18:24:20 | [diff] [blame] | 35 | output.extend(input_api.canned_checks.CheckDoNotSubmit(input_api, |
| 36 | output_api)) |
[email protected] | bbfc80f | 2010-06-22 17:55:15 | [diff] [blame^] | 37 | output.extend(WasGitClUploadHookModified(input_api, output_api)) |
[email protected] | 7b305e8 | 2009-05-19 18:24:20 | [diff] [blame] | 38 | return output |
[email protected] | bbfc80f | 2010-06-22 17:55:15 | [diff] [blame^] | 39 | |
| 40 | def WasGitClUploadHookModified(input_api, output_api): |
| 41 | for affected_file in input_api.AffectedSourceFiles(None): |
| 42 | if (input_api.os_path.basename(affected_file.LocalPath()) == |
| 43 | 'git-cl-upload-hook'): |
| 44 | return [output_api.PresubmitPromptWarning( |
| 45 | 'Don\'t forget to fix git-cl to download the newest version of ' |
| 46 | 'git-cl-upload-hook')] |
| 47 | return [] |