Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: PRESUBMIT.py

Issue 5695007: Enhance RunPylint to use white_list and black_list arguments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: address review comment Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 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 output.extend(input_api.canned_checks.RunPythonUnitTests( 24 output.extend(input_api.canned_checks.RunPythonUnitTests(
25 input_api, 25 input_api,
26 output_api, 26 output_api,
27 UNIT_TESTS)) 27 UNIT_TESTS))
28 output.extend(WasGitClUploadHookModified(input_api, output_api)) 28 output.extend(WasGitClUploadHookModified(input_api, output_api))
29 29
30 def filter_python_sources(affected_file): 30 white_list = [r'.*\.py$', r'.*git-try$']
31 filepath = affected_file.LocalPath() 31 black_list = list(input_api.DEFAULT_BLACK_LIST) + [
32 return ((filepath.endswith('.py') and 32 r'.*cpplint\.py$', r'.*git_cl_repo.*']
33 filepath != 'cpplint.py' and
34 not filepath.startswith('tests')) or
35 filepath == 'git-try')
36
37 output.extend(input_api.canned_checks.RunPylint( 33 output.extend(input_api.canned_checks.RunPylint(
38 input_api, 34 input_api,
39 output_api, 35 output_api,
40 source_file_filter=filter_python_sources)) 36 white_list=white_list,
37 black_list=black_list))
41 return output 38 return output
42 39
43 40
44 def CheckChangeOnUpload(input_api, output_api): 41 def CheckChangeOnUpload(input_api, output_api):
45 return CommonChecks(input_api, output_api) 42 return CommonChecks(input_api, output_api)
46 43
47 44
48 def CheckChangeOnCommit(input_api, output_api): 45 def CheckChangeOnCommit(input_api, output_api):
49 output = [] 46 output = []
50 output.extend(CommonChecks(input_api, output_api)) 47 output.extend(CommonChecks(input_api, output_api))
51 output.extend(input_api.canned_checks.CheckDoNotSubmit( 48 output.extend(input_api.canned_checks.CheckDoNotSubmit(
52 input_api, 49 input_api,
53 output_api)) 50 output_api))
54 return output 51 return output
55 52
56 53
57 def WasGitClUploadHookModified(input_api, output_api): 54 def WasGitClUploadHookModified(input_api, output_api):
58 for affected_file in input_api.AffectedSourceFiles(None): 55 for affected_file in input_api.AffectedSourceFiles(None):
59 if (input_api.os_path.basename(affected_file.LocalPath()) == 56 if (input_api.os_path.basename(affected_file.LocalPath()) ==
60 'git-cl-upload-hook'): 57 'git-cl-upload-hook'):
61 return [output_api.PresubmitPromptWarning( 58 return [output_api.PresubmitPromptWarning(
62 'Don\'t forget to fix git-cl to download the newest version of ' 59 'Don\'t forget to fix git-cl to download the newest version of '
63 'git-cl-upload-hook')] 60 'git-cl-upload-hook')]
64 return [] 61 return []
OLDNEW
« no previous file with comments | « no previous file | presubmit_canned_checks.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698