blob: e7e643dc69bf0e041885e20368ebde5071a441e3 [file] [log] [blame]
Mandeep Singh Baines116ad102011-04-27 15:16:37 -07001# Copyright (c) 2011 The Chromium OS 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
Ryan Cui9b651632011-05-11 11:38:58 -07005import ConfigParser
Dale Curtis2975c432011-05-03 17:25:20 -07006import json
Mandeep Singh Baines116ad102011-04-27 15:16:37 -07007import os
Ryan Cuiec4d6332011-05-02 14:15:25 -07008import re
Mandeep Singh Bainesa7ffa4b2011-05-03 11:37:02 -07009import sys
Mandeep Singh Baines116ad102011-04-27 15:16:37 -070010import subprocess
11
Ryan Cui1562fb82011-05-09 11:01:31 -070012from errors import (VerifyException, HookFailure, PrintErrorForProject,
13 PrintErrorsForCommit)
Ryan Cuiec4d6332011-05-02 14:15:25 -070014
Ryan Cuiec4d6332011-05-02 14:15:25 -070015
16COMMON_INCLUDED_PATHS = [
17 # C++ and friends
18 r".*\.c$", r".*\.cc$", r".*\.cpp$", r".*\.h$", r".*\.m$", r".*\.mm$",
19 r".*\.inl$", r".*\.asm$", r".*\.hxx$", r".*\.hpp$", r".*\.s$", r".*\.S$",
20 # Scripts
21 r".*\.js$", r".*\.py$", r".*\.sh$", r".*\.rb$", r".*\.pl$", r".*\.pm$",
22 # No extension at all, note that ALL CAPS files are black listed in
23 # COMMON_EXCLUDED_LIST below.
24 r"(^|.*?[\\\/])[^.]+$",
25 # Other
26 r".*\.java$", r".*\.mk$", r".*\.am$",
27]
28
Ryan Cui1562fb82011-05-09 11:01:31 -070029
Ryan Cuiec4d6332011-05-02 14:15:25 -070030COMMON_EXCLUDED_PATHS = [
Ryan Cui31e0c172011-05-04 21:00:45 -070031 # avoid doing source file checks for kernel
32 r"/src/third_party/kernel/",
33 r"/src/third_party/kernel-next/",
Paul Taysomf8b6e012011-05-09 14:32:42 -070034 r"/src/third_party/ktop/",
35 r"/src/third_party/punybench/",
Ryan Cuiec4d6332011-05-02 14:15:25 -070036 r".*\bexperimental[\\\/].*",
37 r".*\b[A-Z0-9_]{2,}$",
38 r".*[\\\/]debian[\\\/]rules$",
39]
Mandeep Singh Baines116ad102011-04-27 15:16:37 -070040
Ryan Cui1562fb82011-05-09 11:01:31 -070041
Ryan Cui9b651632011-05-11 11:38:58 -070042_CONFIG_FILE = 'PRESUBMIT.cfg'
43
44
Ryan Cui1562fb82011-05-09 11:01:31 -070045# General Helpers
46
Sean Paulba01d402011-05-05 11:36:23 -040047
Ryan Cui72834d12011-05-05 14:51:33 -070048def _run_command(cmd):
49 """Executes the passed in command and returns raw stdout output."""
50 return subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
51
Ryan Cui1562fb82011-05-09 11:01:31 -070052
Mandeep Singh Baines116ad102011-04-27 15:16:37 -070053def _get_hooks_dir():
Ryan Cuiec4d6332011-05-02 14:15:25 -070054 """Returns the absolute path to the repohooks directory."""
Mandeep Singh Baines116ad102011-04-27 15:16:37 -070055 cmd = ['repo', 'forall', 'chromiumos/repohooks', '-c', 'pwd']
Ryan Cui72834d12011-05-05 14:51:33 -070056 return _run_command(cmd).strip()
Mandeep Singh Baines116ad102011-04-27 15:16:37 -070057
Ryan Cui1562fb82011-05-09 11:01:31 -070058
Ryan Cuiec4d6332011-05-02 14:15:25 -070059def _match_regex_list(subject, expressions):
60 """Try to match a list of regular expressions to a string.
61
62 Args:
63 subject: The string to match regexes on
64 expressions: A list of regular expressions to check for matches with.
65
66 Returns:
67 Whether the passed in subject matches any of the passed in regexes.
68 """
69 for expr in expressions:
70 if (re.search(expr, subject)):
71 return True
72 return False
73
Ryan Cui1562fb82011-05-09 11:01:31 -070074
Ryan Cuiec4d6332011-05-02 14:15:25 -070075def _filter_files(files, include_list, exclude_list=[]):
76 """Filter out files based on the conditions passed in.
77
78 Args:
79 files: list of filepaths to filter
80 include_list: list of regex that when matched with a file path will cause it
81 to be added to the output list unless the file is also matched with a
82 regex in the exclude_list.
83 exclude_list: list of regex that when matched with a file will prevent it
84 from being added to the output list, even if it is also matched with a
85 regex in the include_list.
86
87 Returns:
88 A list of filepaths that contain files matched in the include_list and not
89 in the exclude_list.
90 """
91 filtered = []
92 for f in files:
93 if (_match_regex_list(f, include_list) and
94 not _match_regex_list(f, exclude_list)):
95 filtered.append(f)
96 return filtered
97
Ryan Cuiec4d6332011-05-02 14:15:25 -070098
99# Git Helpers
Ryan Cui1562fb82011-05-09 11:01:31 -0700100
101
Ryan Cui4725d952011-05-05 15:41:19 -0700102def _get_upstream_branch():
103 """Returns the upstream tracking branch of the current branch.
104
105 Raises:
106 Error if there is no tracking branch
107 """
108 current_branch = _run_command(['git', 'symbolic-ref', 'HEAD']).strip()
109 current_branch = current_branch.replace('refs/heads/', '')
110 if not current_branch:
Ryan Cui1562fb82011-05-09 11:01:31 -0700111 raise VerifyException('Need to be on a tracking branch')
Ryan Cui4725d952011-05-05 15:41:19 -0700112
113 cfg_option = 'branch.' + current_branch + '.%s'
114 full_upstream = _run_command(['git', 'config', cfg_option % 'merge']).strip()
115 remote = _run_command(['git', 'config', cfg_option % 'remote']).strip()
116 if not remote or not full_upstream:
Ryan Cui1562fb82011-05-09 11:01:31 -0700117 raise VerifyException('Need to be on a tracking branch')
Ryan Cui4725d952011-05-05 15:41:19 -0700118
119 return full_upstream.replace('heads', 'remotes/' + remote)
120
Ryan Cui1562fb82011-05-09 11:01:31 -0700121
Mandeep Singh Bainesb9ed1402011-04-29 15:32:06 -0700122def _get_diff(commit):
Ryan Cuiec4d6332011-05-02 14:15:25 -0700123 """Returns the diff for this commit."""
Ryan Cui72834d12011-05-05 14:51:33 -0700124 return _run_command(['git', 'show', commit])
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700125
Ryan Cui1562fb82011-05-09 11:01:31 -0700126
Ryan Cuiec4d6332011-05-02 14:15:25 -0700127def _get_file_diff(file, commit):
128 """Returns a list of (linenum, lines) tuples that the commit touched."""
Ryan Cui72834d12011-05-05 14:51:33 -0700129 output = _run_command(['git', 'show', '-p', '--no-ext-diff', commit, file])
Ryan Cuiec4d6332011-05-02 14:15:25 -0700130
131 new_lines = []
132 line_num = 0
133 for line in output.splitlines():
134 m = re.match(r'^@@ [0-9\,\+\-]+ \+([0-9]+)\,[0-9]+ @@', line)
135 if m:
136 line_num = int(m.groups(1)[0])
137 continue
138 if line.startswith('+') and not line.startswith('++'):
139 new_lines.append((line_num, line[1:]))
140 if not line.startswith('-'):
141 line_num += 1
142 return new_lines
143
Ryan Cui1562fb82011-05-09 11:01:31 -0700144
Ryan Cuiec4d6332011-05-02 14:15:25 -0700145def _get_affected_files(commit):
146 """Returns list of absolute filepaths that were modified/added."""
Ryan Cui72834d12011-05-05 14:51:33 -0700147 output = _run_command(['git', 'diff', '--name-status', commit + '^!'])
Ryan Cuiec4d6332011-05-02 14:15:25 -0700148 files = []
149 for statusline in output.splitlines():
150 m = re.match('^(\w)+\t(.+)$', statusline.rstrip())
151 # Ignore deleted files, and return absolute paths of files
152 if (m.group(1)[0] != 'D'):
153 pwd = os.getcwd()
154 files.append(os.path.join(pwd, m.group(2)))
155 return files
156
Ryan Cui1562fb82011-05-09 11:01:31 -0700157
Mandeep Singh Bainesb9ed1402011-04-29 15:32:06 -0700158def _get_commits():
Ryan Cuiec4d6332011-05-02 14:15:25 -0700159 """Returns a list of commits for this review."""
Ryan Cui4725d952011-05-05 15:41:19 -0700160 cmd = ['git', 'log', '%s..' % _get_upstream_branch(), '--format=%H']
Ryan Cui72834d12011-05-05 14:51:33 -0700161 return _run_command(cmd).split()
Mandeep Singh Bainesb9ed1402011-04-29 15:32:06 -0700162
Ryan Cui1562fb82011-05-09 11:01:31 -0700163
Ryan Cuiec4d6332011-05-02 14:15:25 -0700164def _get_commit_desc(commit):
165 """Returns the full commit message of a commit."""
Sean Paul23a2c582011-05-06 13:10:44 -0400166 return _run_command(['git', 'log', '--format=%s%n%n%b', commit + '^!'])
Ryan Cuiec4d6332011-05-02 14:15:25 -0700167
168
169# Common Hooks
170
Ryan Cui1562fb82011-05-09 11:01:31 -0700171
Ryan Cuiec4d6332011-05-02 14:15:25 -0700172def _check_no_long_lines(project, commit):
173 """Checks that there aren't any lines longer than maxlen characters in any of
174 the text files to be submitted.
175 """
176 MAX_LEN = 80
177
178 errors = []
179 files = _filter_files(_get_affected_files(commit),
180 COMMON_INCLUDED_PATHS,
181 COMMON_EXCLUDED_PATHS)
182
183 for afile in files:
184 for line_num, line in _get_file_diff(afile, commit):
185 # Allow certain lines to exceed the maxlen rule.
186 if (len(line) > MAX_LEN and
187 not 'http://' in line and
188 not 'https://' in line and
189 not line.startswith('#define') and
190 not line.startswith('#include') and
191 not line.startswith('#import') and
192 not line.startswith('#pragma') and
193 not line.startswith('#if') and
194 not line.startswith('#endif')):
195 errors.append('%s, line %s, %s chars' % (afile, line_num, len(line)))
196 if len(errors) == 5: # Just show the first 5 errors.
197 break
198
199 if errors:
200 msg = 'Found lines longer than %s characters (first 5 shown):' % MAX_LEN
Ryan Cui1562fb82011-05-09 11:01:31 -0700201 return HookFailure(msg, errors)
202
Ryan Cuiec4d6332011-05-02 14:15:25 -0700203
204def _check_no_stray_whitespace(project, commit):
205 """Checks that there is no stray whitespace at source lines end."""
206 errors = []
207 files = _filter_files(_get_affected_files(commit),
208 COMMON_INCLUDED_PATHS,
209 COMMON_EXCLUDED_PATHS)
210
211 for afile in files:
212 for line_num, line in _get_file_diff(afile, commit):
213 if line.rstrip() != line:
214 errors.append('%s, line %s' % (afile, line_num))
215 if errors:
Ryan Cui1562fb82011-05-09 11:01:31 -0700216 return HookFailure('Found line ending with white space in:', errors)
217
Ryan Cuiec4d6332011-05-02 14:15:25 -0700218
219def _check_no_tabs(project, commit):
220 """Checks there are no unexpanded tabs."""
221 TAB_OK_PATHS = [
Ryan Cui31e0c172011-05-04 21:00:45 -0700222 r"/src/third_party/u-boot/",
Ryan Cuiec4d6332011-05-02 14:15:25 -0700223 r".*\.ebuild$",
224 r".*\.eclass$",
225 r".*/[M|m]akefile$"
226 ]
227
228 errors = []
229 files = _filter_files(_get_affected_files(commit),
230 COMMON_INCLUDED_PATHS,
231 COMMON_EXCLUDED_PATHS + TAB_OK_PATHS)
232
233 for afile in files:
234 for line_num, line in _get_file_diff(afile, commit):
235 if '\t' in line:
236 errors.append('%s, line %s' % (afile, line_num))
237 if errors:
Ryan Cui1562fb82011-05-09 11:01:31 -0700238 return HookFailure('Found a tab character in:', errors)
239
Ryan Cuiec4d6332011-05-02 14:15:25 -0700240
241def _check_change_has_test_field(project, commit):
242 """Check for a non-empty 'TEST=' field in the commit message."""
David McMahon8f6553e2011-06-10 15:46:36 -0700243 TEST_RE = r'\nTEST=\S+'
Ryan Cuiec4d6332011-05-02 14:15:25 -0700244
Mandeep Singh Baines96a53be2011-05-03 11:10:25 -0700245 if not re.search(TEST_RE, _get_commit_desc(commit)):
Ryan Cui1562fb82011-05-09 11:01:31 -0700246 msg = 'Changelist description needs TEST field (after first line)'
247 return HookFailure(msg)
248
Ryan Cuiec4d6332011-05-02 14:15:25 -0700249
250def _check_change_has_bug_field(project, commit):
David McMahon8f6553e2011-06-10 15:46:36 -0700251 """Check for a correctly formatted 'BUG=' field in the commit message."""
252 BUG_RE = r'\nBUG=([Nn]one|(chrome-os-partner|chromium-os):\d+)'
Ryan Cuiec4d6332011-05-02 14:15:25 -0700253
Mandeep Singh Baines96a53be2011-05-03 11:10:25 -0700254 if not re.search(BUG_RE, _get_commit_desc(commit)):
David McMahon8f6553e2011-06-10 15:46:36 -0700255 msg = ('Changelist description needs BUG field (after first line):\n'
256 'BUG=chromium-os:99999 (for public tracker)\n'
257 'BUG=chrome-os-partner:9999 (for partner tracker)\n'
258 'BUG=None')
Ryan Cui1562fb82011-05-09 11:01:31 -0700259 return HookFailure(msg)
260
Ryan Cuiec4d6332011-05-02 14:15:25 -0700261
Mandeep Singh Bainesa23eb5f2011-05-04 13:43:25 -0700262def _check_change_has_proper_changeid(project, commit):
263 """Verify that Change-ID is present in last paragraph of commit message."""
264 desc = _get_commit_desc(commit)
265 loc = desc.rfind('\nChange-Id:')
266 if loc == -1 or re.search('\n\s*\n\s*\S+', desc[loc:]):
Ryan Cui1562fb82011-05-09 11:01:31 -0700267 return HookFailure('Change-Id must be in last paragraph of description.')
268
Mandeep Singh Bainesa23eb5f2011-05-04 13:43:25 -0700269
Ryan Cuiec4d6332011-05-02 14:15:25 -0700270def _check_license(project, commit):
271 """Verifies the license header."""
272 LICENSE_HEADER = (
273 r".*? Copyright \(c\) 20[-0-9]{2,7} The Chromium OS Authors\. All rights "
274 r"reserved\." "\n"
275 r".*? Use of this source code is governed by a BSD-style license that can "
276 "be\n"
277 r".*? found in the LICENSE file\."
278 "\n"
279 )
280
281 license_re = re.compile(LICENSE_HEADER, re.MULTILINE)
282 bad_files = []
283 files = _filter_files(_get_affected_files(commit),
284 COMMON_INCLUDED_PATHS,
285 COMMON_EXCLUDED_PATHS)
286
287 for f in files:
288 contents = open(f).read()
289 if len(contents) == 0: continue # Ignore empty files
290 if not license_re.search(contents):
291 bad_files.append(f)
292 if bad_files:
Ryan Cui1562fb82011-05-09 11:01:31 -0700293 return HookFailure('License must match:\n%s\n' % license_re.pattern +
294 'Found a bad license header in these files:',
295 bad_files)
Ryan Cuiec4d6332011-05-02 14:15:25 -0700296
297
298# Project-specific hooks
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700299
Ryan Cui1562fb82011-05-09 11:01:31 -0700300
Anton Staaf815d6852011-08-22 10:08:45 -0700301def _run_checkpatch(project, commit, options=[]):
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700302 """Runs checkpatch.pl on the given project"""
303 hooks_dir = _get_hooks_dir()
Anton Staaf815d6852011-08-22 10:08:45 -0700304 cmd = ['%s/checkpatch.pl' % hooks_dir] + options + ['-']
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700305 p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
Mandeep Singh Bainesb9ed1402011-04-29 15:32:06 -0700306 output = p.communicate(_get_diff(commit))[0]
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700307 if p.returncode:
Ryan Cui1562fb82011-05-09 11:01:31 -0700308 return HookFailure('checkpatch.pl errors/warnings\n\n' + output)
Ryan Cuiec4d6332011-05-02 14:15:25 -0700309
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700310
Anton Staaf815d6852011-08-22 10:08:45 -0700311def _run_checkpatch_no_tree(project, commit):
312 return _run_checkpatch(project, commit, ['--no-tree'])
313
314
Dale Curtis2975c432011-05-03 17:25:20 -0700315def _run_json_check(project, commit):
316 """Checks that all JSON files are syntactically valid."""
Dale Curtisa039cfd2011-05-04 12:01:05 -0700317 for f in _filter_files(_get_affected_files(commit), [r'.*\.json']):
Dale Curtis2975c432011-05-03 17:25:20 -0700318 try:
319 json.load(open(f))
320 except Exception, e:
Ryan Cui1562fb82011-05-09 11:01:31 -0700321 return HookFailure('Invalid JSON in %s: %s' % (f, e))
Dale Curtis2975c432011-05-03 17:25:20 -0700322
323
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700324# Base
325
Ryan Cui1562fb82011-05-09 11:01:31 -0700326
Ryan Cui9b651632011-05-11 11:38:58 -0700327# A list of hooks that are not project-specific
328_COMMON_HOOKS = [
329 _check_change_has_bug_field,
330 _check_change_has_test_field,
331 _check_change_has_proper_changeid,
332 _check_no_stray_whitespace,
333 _check_no_long_lines,
334 _check_license,
335 _check_no_tabs,
336]
Ryan Cuiec4d6332011-05-02 14:15:25 -0700337
Ryan Cui1562fb82011-05-09 11:01:31 -0700338
Ryan Cui9b651632011-05-11 11:38:58 -0700339# A dictionary of project-specific hooks(callbacks), indexed by project name.
340# dict[project] = [callback1, callback2]
341_PROJECT_SPECIFIC_HOOKS = {
Doug Anderson830216f2011-05-02 10:08:37 -0700342 "chromiumos/third_party/kernel": [_run_checkpatch],
343 "chromiumos/third_party/kernel-next": [_run_checkpatch],
Anton Staaf815d6852011-08-22 10:08:45 -0700344 "chromiumos/third_party/u-boot": [_run_checkpatch_no_tree],
Dale Curtis2975c432011-05-03 17:25:20 -0700345 "chromeos/autotest-tools": [_run_json_check],
Ryan Cui9b651632011-05-11 11:38:58 -0700346}
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700347
Ryan Cui1562fb82011-05-09 11:01:31 -0700348
Ryan Cui9b651632011-05-11 11:38:58 -0700349# A dictionary of flags (keys) that can appear in the config file, and the hook
350# that the flag disables (value)
351_DISABLE_FLAGS = {
352 'stray_whitespace_check': _check_no_stray_whitespace,
353 'long_line_check': _check_no_long_lines,
354 'cros_license_check': _check_license,
355 'tab_check': _check_no_tabs,
356}
357
358
359def _get_disabled_hooks():
360 """Returns a set of hooks disabled by the current project's config file.
361
362 Expects to be called within the project root.
363 """
364 SECTION = 'Hook Overrides'
365 config = ConfigParser.RawConfigParser()
366 try:
367 config.read(_CONFIG_FILE)
368 flags = config.options(SECTION)
369 except ConfigParser.Error:
370 return set([])
371
372 disable_flags = []
373 for flag in flags:
374 try:
375 if not config.getboolean(SECTION, flag): disable_flags.append(flag)
376 except ValueError as e:
377 msg = "Error parsing flag \'%s\' in %s file - " % (flag, _CONFIG_FILE)
378 print msg + str(e)
379
380 disabled_keys = set(_DISABLE_FLAGS.iterkeys()).intersection(disable_flags)
381 return set([_DISABLE_FLAGS[key] for key in disabled_keys])
382
383
384def _get_project_hooks(project):
385 """Returns a list of hooks that need to be run for a project.
386
387 Expects to be called from within the project root.
388 """
389 disabled_hooks = _get_disabled_hooks()
390 hooks = [hook for hook in _COMMON_HOOKS if hook not in disabled_hooks]
391
392 if project in _PROJECT_SPECIFIC_HOOKS:
393 hooks.extend(_PROJECT_SPECIFIC_HOOKS[project])
394
395 return hooks
396
397
398def _run_project_hooks(project):
Ryan Cui1562fb82011-05-09 11:01:31 -0700399 """For each project run its project specific hook from the hooks dictionary.
400
401 Args:
402 project: name of project to run hooks for.
Ryan Cui1562fb82011-05-09 11:01:31 -0700403
404 Returns:
405 Boolean value of whether any errors were ecountered while running the hooks.
406 """
Ryan Cui72834d12011-05-05 14:51:33 -0700407 proj_dir = _run_command(['repo', 'forall', project, '-c', 'pwd']).strip()
Ryan Cuiec4d6332011-05-02 14:15:25 -0700408 pwd = os.getcwd()
409 # hooks assume they are run from the root of the project
410 os.chdir(proj_dir)
411
Ryan Cuifa55df52011-05-06 11:16:55 -0700412 try:
413 commit_list = _get_commits()
Don Garrettdba548a2011-05-05 15:17:14 -0700414 except VerifyException as e:
Ryan Cui1562fb82011-05-09 11:01:31 -0700415 PrintErrorForProject(project, HookFailure(str(e)))
416 os.chdir(pwd)
417 return True
Ryan Cuifa55df52011-05-06 11:16:55 -0700418
Ryan Cui9b651632011-05-11 11:38:58 -0700419 hooks = _get_project_hooks(project)
Ryan Cui1562fb82011-05-09 11:01:31 -0700420 error_found = False
Ryan Cuifa55df52011-05-06 11:16:55 -0700421 for commit in commit_list:
Ryan Cui1562fb82011-05-09 11:01:31 -0700422 error_list = []
Ryan Cui9b651632011-05-11 11:38:58 -0700423 for hook in hooks:
Ryan Cui1562fb82011-05-09 11:01:31 -0700424 hook_error = hook(project, commit)
425 if hook_error:
426 error_list.append(hook_error)
427 error_found = True
428 if error_list:
429 PrintErrorsForCommit(project, commit, _get_commit_desc(commit),
430 error_list)
Don Garrettdba548a2011-05-05 15:17:14 -0700431
Ryan Cuiec4d6332011-05-02 14:15:25 -0700432 os.chdir(pwd)
Ryan Cui1562fb82011-05-09 11:01:31 -0700433 return error_found
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700434
Ryan Cui72834d12011-05-05 14:51:33 -0700435
Mandeep Singh Baines116ad102011-04-27 15:16:37 -0700436# Main
Mandeep Singh Baines69e470e2011-04-06 10:34:52 -0700437
Ryan Cui1562fb82011-05-09 11:01:31 -0700438
Anush Elangovan63afad72011-03-23 00:41:27 -0700439def main(project_list, **kwargs):
Ryan Cui1562fb82011-05-09 11:01:31 -0700440 found_error = False
441 for project in project_list:
Ryan Cui9b651632011-05-11 11:38:58 -0700442 if _run_project_hooks(project):
Ryan Cui1562fb82011-05-09 11:01:31 -0700443 found_error = True
444
445 if (found_error):
446 msg = ('Preupload failed due to errors in project(s). HINTS:\n'
Ryan Cui9b651632011-05-11 11:38:58 -0700447 '- To disable some source style checks, and for other hints, see '
448 '<checkout_dir>/src/repohooks/README\n'
449 '- To upload only current project, run \'repo upload .\'')
Ryan Cui1562fb82011-05-09 11:01:31 -0700450 print >> sys.stderr, msg
Don Garrettdba548a2011-05-05 15:17:14 -0700451 sys.exit(1)
Anush Elangovan63afad72011-03-23 00:41:27 -0700452
Ryan Cui1562fb82011-05-09 11:01:31 -0700453
Mandeep Singh Baines69e470e2011-04-06 10:34:52 -0700454if __name__ == '__main__':
455 main()