blob: 4a4f85797c1b1e8129c95f15fe035e5ed090a501 [file] [log] [blame]
[email protected]1f7b4172010-01-28 01:17:341# Copyright (c) 2010 The Chromium Authors. All rights reserved.
[email protected]ca8d1982009-02-19 16:33:122# 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 Chromium.
6
[email protected]f1293792009-07-31 18:09:567See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
[email protected]50d7d721e2009-11-15 17:56:188for more details about the presubmit API built into gcl.
[email protected]ca8d1982009-02-19 16:33:129"""
10
[email protected]379e7dd2010-01-28 17:39:2111_EXCLUDED_PATHS = (
[email protected]33478702009-03-05 14:03:1412 r"breakpad[\\\/].*",
[email protected]abc6a512010-08-04 01:25:4213 r"net/tools/spdyshark/[\\\/].*",
[email protected]33478702009-03-05 14:03:1414 r"skia[\\\/].*",
[email protected]33478702009-03-05 14:03:1415 r"v8[\\\/].*",
[email protected]4306417642009-06-11 00:33:4016)
[email protected]ca8d1982009-02-19 16:33:1217
[email protected]379e7dd2010-01-28 17:39:2118_TEXT_FILES = (
19 r".*\.txt",
20 r".*\.json",
21)
[email protected]ca8d1982009-02-19 16:33:1222
[email protected]1f7b4172010-01-28 01:17:3423_LICENSE_HEADER = (
[email protected]38fdd9d2010-01-28 18:33:2224 r".*? Copyright \(c\) 20[0-9\-]{2,7} The Chromium Authors\. All rights "
25 r"reserved\." "\n"
[email protected]1f7b4172010-01-28 01:17:3426 r".*? Use of this source code is governed by a BSD-style license that can "
27 "be\n"
28 r".*? found in the LICENSE file\."
29 "\n"
30)
31
32
[email protected]542d1ad22010-08-04 17:50:5533def _CheckConstNSObject(input_api, output_api, source_file_filter):
34 """Checks to make sure no objective-c files have |const NSSomeClass*|."""
35 pattern = input_api.re.compile(r'const\s+NS\w*\s*\*')
36 files = []
37 for f in input_api.AffectedSourceFiles(source_file_filter):
38 if f.LocalPath().endswith('.h') or f.LocalPath().endswith('.mm'):
39 contents = input_api.ReadFile(f)
40 if pattern.search(contents):
41 files.append(f)
42
43 if len(files):
44 if input_api.is_committing:
45 res_type = output_api.PresubmitPromptWarning
46 else:
47 res_type = output_api.PresubmitNotifyResult
48 return [ res_type('|const NSClass*| is wrong, see ' +
49 'http://dev.chromium.org/developers/clang-mac',
50 files) ]
51 return []
52
53
[email protected]1f7b4172010-01-28 01:17:3454def _CommonChecks(input_api, output_api):
[email protected]fe5f57c52009-06-05 14:25:5455 results = []
[email protected]4306417642009-06-11 00:33:4056 # What does this code do?
57 # It loads the default black list (e.g. third_party, experimental, etc) and
58 # add our black list (breakpad, skia and v8 are still not following
59 # google style and are not really living this repository).
60 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage.
[email protected]379e7dd2010-01-28 17:39:2161 black_list = input_api.DEFAULT_BLACK_LIST + _EXCLUDED_PATHS
62 white_list = input_api.DEFAULT_WHITE_LIST + _TEXT_FILES
[email protected]4306417642009-06-11 00:33:4063 sources = lambda x: input_api.FilterSourceFile(x, black_list=black_list)
[email protected]379e7dd2010-01-28 17:39:2164 text_files = lambda x: input_api.FilterSourceFile(x, black_list=black_list,
65 white_list=white_list)
[email protected]4306417642009-06-11 00:33:4066 results.extend(input_api.canned_checks.CheckLongLines(
[email protected]ea1413862010-05-05 23:24:5367 input_api, output_api, source_file_filter=sources))
[email protected]4306417642009-06-11 00:33:4068 results.extend(input_api.canned_checks.CheckChangeHasNoTabs(
[email protected]ea1413862010-05-05 23:24:5369 input_api, output_api, source_file_filter=sources))
[email protected]4306417642009-06-11 00:33:4070 results.extend(input_api.canned_checks.CheckChangeHasNoStrayWhitespace(
[email protected]ea1413862010-05-05 23:24:5371 input_api, output_api, source_file_filter=sources))
[email protected]4306417642009-06-11 00:33:4072 results.extend(input_api.canned_checks.CheckChangeHasBugField(
73 input_api, output_api))
74 results.extend(input_api.canned_checks.CheckChangeHasTestField(
75 input_api, output_api))
76 results.extend(input_api.canned_checks.CheckChangeSvnEolStyle(
[email protected]ea1413862010-05-05 23:24:5377 input_api, output_api, source_file_filter=text_files))
[email protected]40cdf8b32009-06-26 23:00:3778 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
79 input_api, output_api))
[email protected]1f7b4172010-01-28 01:17:3480 results.extend(input_api.canned_checks.CheckLicense(
[email protected]ea1413862010-05-05 23:24:5381 input_api, output_api, _LICENSE_HEADER, source_file_filter=sources))
[email protected]542d1ad22010-08-04 17:50:5582 results.extend(_CheckConstNSObject(
83 input_api, output_api, source_file_filter=sources))
[email protected]1f7b4172010-01-28 01:17:3484 return results
85
86
87def CheckChangeOnUpload(input_api, output_api):
88 results = []
89 results.extend(_CommonChecks(input_api, output_api))
[email protected]fe5f57c52009-06-05 14:25:5490 return results
[email protected]ca8d1982009-02-19 16:33:1291
92
93def CheckChangeOnCommit(input_api, output_api):
[email protected]fe5f57c52009-06-05 14:25:5494 results = []
[email protected]806e98e2010-03-19 17:49:2795 if not input_api.json:
96 results.append(output_api.PresubmitNotifyResult(
97 'You don\'t have json nor simplejson installed.\n'
98 ' This is a warning that you will need to upgrade your python '
99 'installation.\n'
100 ' This is no big deal but you\'ll eventually need to '
101 'upgrade.\n'
102 ' How? Easy! You can do it right now and shut me off! Just:\n'
103 ' del depot_tools\\python.bat\n'
104 ' gclient\n'
105 ' Thanks for your patience.'))
[email protected]1f7b4172010-01-28 01:17:34106 results.extend(_CommonChecks(input_api, output_api))
[email protected]dd805fe2009-10-01 08:11:51107 # TODO(thestig) temporarily disabled, doesn't work in third_party/
108 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
109 # input_api, output_api, sources))
[email protected]fe5f57c52009-06-05 14:25:54110 # Make sure the tree is 'open'.
[email protected]806e98e2010-03-19 17:49:27111 results.extend(input_api.canned_checks.CheckTreeIsOpen(
[email protected]7f238152009-08-12 19:00:34112 input_api,
113 output_api,
[email protected]4efa42142010-08-26 01:29:26114 json_url='http://chromium-status.appspot.com/current?format=json'))
[email protected]806e98e2010-03-19 17:49:27115 results.extend(input_api.canned_checks.CheckRietveldTryJobExecution(input_api,
116 output_api, 'http://codereview.chromium.org', ('win', 'linux', 'mac'),
117 '[email protected]'))
118
[email protected]7fa42f12009-11-09 20:54:16119 # These builders are just too slow.
120 IGNORED_BUILDERS = [
121 'Chromium XP',
[email protected]7fa42f12009-11-09 20:54:16122 'Chromium Mac',
[email protected]01333922010-02-02 21:25:02123 'Chromium Arm (dbg)',
[email protected]7fa42f12009-11-09 20:54:16124 'Chromium Linux',
125 'Chromium Linux x64',
[email protected]7fa42f12009-11-09 20:54:16126 ]
[email protected]806e98e2010-03-19 17:49:27127 results.extend(input_api.canned_checks.CheckBuildbotPendingBuilds(
[email protected]7fa42f12009-11-09 20:54:16128 input_api,
129 output_api,
[email protected]806e98e2010-03-19 17:49:27130 'http://build.chromium.org/buildbot/waterfall/json/builders?filter=1',
[email protected]7fa42f12009-11-09 20:54:16131 6,
132 IGNORED_BUILDERS))
[email protected]fe5f57c52009-06-05 14:25:54133 return results
[email protected]ca8d1982009-02-19 16:33:12134
135
[email protected]5fa06292009-09-29 01:55:00136def GetPreferredTrySlaves():
137 return ['win', 'linux', 'mac']