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

Side by Side Diff: presubmit_canned_checks.py

Issue 1449853002: depot_tools: make CheckLicense warn instead of notify (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | tests/presubmit_unittest.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) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Generic presubmit checks that can be reused by other presubmit checks.""" 5 """Generic presubmit checks that can be reused by other presubmit checks."""
6 6
7 import os as _os 7 import os as _os
8 _HERE = _os.path.dirname(_os.path.abspath(__file__)) 8 _HERE = _os.path.dirname(_os.path.abspath(__file__))
9 9
10 # Justifications for each filter: 10 # Justifications for each filter:
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 """ 412 """
413 license_re = input_api.re.compile(license_re, input_api.re.MULTILINE) 413 license_re = input_api.re.compile(license_re, input_api.re.MULTILINE)
414 bad_files = [] 414 bad_files = []
415 for f in input_api.AffectedSourceFiles(source_file_filter): 415 for f in input_api.AffectedSourceFiles(source_file_filter):
416 contents = input_api.ReadFile(f, 'rb') 416 contents = input_api.ReadFile(f, 'rb')
417 if accept_empty_files and not contents: 417 if accept_empty_files and not contents:
418 continue 418 continue
419 if not license_re.search(contents): 419 if not license_re.search(contents):
420 bad_files.append(f.LocalPath()) 420 bad_files.append(f.LocalPath())
421 if bad_files: 421 if bad_files:
422 if input_api.is_committing: 422 return [output_api.PresubmitPromptWarning(
423 res_type = output_api.PresubmitPromptWarning
424 else:
425 res_type = output_api.PresubmitNotifyResult
426 return [res_type(
427 'License must match:\n%s\n' % license_re.pattern + 423 'License must match:\n%s\n' % license_re.pattern +
428 'Found a bad license header in these files:', items=bad_files)] 424 'Found a bad license header in these files:', items=bad_files)]
429 return [] 425 return []
430 426
431 427
432 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): 428 def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None):
433 """Checks that the source files have svn:eol-style=LF.""" 429 """Checks that the source files have svn:eol-style=LF."""
434 return CheckSvnProperty(input_api, output_api, 430 return CheckSvnProperty(input_api, output_api,
435 'svn:eol-style', 'LF', 431 'svn:eol-style', 'LF',
436 input_api.AffectedSourceFiles(source_file_filter)) 432 input_api.AffectedSourceFiles(source_file_filter))
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 for f in affected_files: 1152 for f in affected_files:
1157 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()] 1153 cmd = ['gn', 'format', '--dry-run', f.AbsoluteLocalPath()]
1158 rc = gn.main(cmd) 1154 rc = gn.main(cmd)
1159 if rc == 2: 1155 if rc == 2:
1160 warnings.append(output_api.PresubmitPromptWarning( 1156 warnings.append(output_api.PresubmitPromptWarning(
1161 '%s requires formatting. Please run `gn format --in-place %s`.' % ( 1157 '%s requires formatting. Please run `gn format --in-place %s`.' % (
1162 f.AbsoluteLocalPath(), f.LocalPath()))) 1158 f.AbsoluteLocalPath(), f.LocalPath())))
1163 # It's just a warning, so ignore other types of failures assuming they'll be 1159 # It's just a warning, so ignore other types of failures assuming they'll be
1164 # caught elsewhere. 1160 # caught elsewhere.
1165 return warnings 1161 return warnings
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698