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

Side by Side Diff: presubmit_canned_checks.py

Issue 9379005: [depot_tools] Use git fetch to optimize the properly configured that use git-svn (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: regex tweak Created 8 years, 10 months 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
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 7
8 ### Description checks 8 ### Description checks
9 9
10 def CheckChangeHasTestField(input_api, output_api): 10 def CheckChangeHasTestField(input_api, output_api):
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 def CheckLicense(input_api, output_api, license_re, source_file_filter=None, 347 def CheckLicense(input_api, output_api, license_re, source_file_filter=None,
348 accept_empty_files=True): 348 accept_empty_files=True):
349 """Verifies the license header. 349 """Verifies the license header.
350 """ 350 """
351 license_re = input_api.re.compile(license_re, input_api.re.MULTILINE) 351 license_re = input_api.re.compile(license_re, input_api.re.MULTILINE)
352 bad_files = [] 352 bad_files = []
353 for f in input_api.AffectedSourceFiles(source_file_filter): 353 for f in input_api.AffectedSourceFiles(source_file_filter):
354 contents = input_api.ReadFile(f, 'rb') 354 contents = input_api.ReadFile(f, 'rb')
355 if accept_empty_files and not contents: 355 if accept_empty_files and not contents:
356 continue 356 continue
357 if not license_re.search(contents): 357 if not license_re.search(contents):
Dan Beam 2012/02/11 02:45:53 It doesn't check for this group at all.
M-A Ruel 2012/02/11 02:51:19 It?
358 bad_files.append(f.LocalPath()) 358 bad_files.append(f.LocalPath())
359 if bad_files: 359 if bad_files:
360 if input_api.is_committing: 360 if input_api.is_committing:
361 res_type = output_api.PresubmitPromptWarning 361 res_type = output_api.PresubmitPromptWarning
362 else: 362 else:
363 res_type = output_api.PresubmitNotifyResult 363 res_type = output_api.PresubmitNotifyResult
364 return [res_type( 364 return [res_type(
365 'License must match:\n%s\n' % license_re.pattern + 365 'License must match:\n%s\n' % license_re.pattern +
366 'Found a bad license header in these files:', items=bad_files)] 366 'Found a bad license header in these files:', items=bad_files)]
367 return [] 367 return []
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 text_files = tuple(text_files or ( 849 text_files = tuple(text_files or (
850 r'.+\.txt$', 850 r'.+\.txt$',
851 r'.+\.json$', 851 r'.+\.json$',
852 )) 852 ))
853 project_name = project_name or 'Chromium' 853 project_name = project_name or 'Chromium'
854 license_header = license_header or ( 854 license_header = license_header or (
855 r'.*? Copyright \(c\) %(year)s The %(project)s Authors\. ' 855 r'.*? Copyright \(c\) %(year)s The %(project)s Authors\. '
856 r'All rights reserved\.\n' 856 r'All rights reserved\.\n'
857 r'.*? Use of this source code is governed by a BSD-style license that ' 857 r'.*? Use of this source code is governed by a BSD-style license that '
858 r'can be\n' 858 r'can be\n'
859 r'.*? found in the LICENSE file\.( \*/)?\n' 859 r'.*? found in the LICENSE file\.(?: \*/)?\n'
M-A Ruel 2012/02/11 02:38:08 Humm I'd rather have that in a separate CL.
Dan Beam 2012/02/11 02:42:36 I've never done it because it'd be a 2 char CL, an
860 ) % { 860 ) % {
861 'year': input_api.time.strftime('%Y'), 861 'year': input_api.time.strftime('%Y'),
862 'project': project_name, 862 'project': project_name,
863 } 863 }
864 864
865 results = [] 865 results = []
866 # This code loads the default black list (e.g. third_party, experimental, etc) 866 # This code loads the default black list (e.g. third_party, experimental, etc)
867 # and add our black list (breakpad, skia and v8 are still not following 867 # and add our black list (breakpad, skia and v8 are still not following
868 # google style and are not really living this repository). 868 # google style and are not really living this repository).
869 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage. 869 # See presubmit_support.py InputApi.FilterSourceFile for the (simple) usage.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes( 914 results.extend(input_api.canned_checks.CheckSvnForCommonMimeTypes(
915 input_api, output_api)) 915 input_api, output_api))
916 snapshot("checking license") 916 snapshot("checking license")
917 results.extend(input_api.canned_checks.CheckLicense( 917 results.extend(input_api.canned_checks.CheckLicense(
918 input_api, output_api, license_header, source_file_filter=sources)) 918 input_api, output_api, license_header, source_file_filter=sources))
919 snapshot("checking was uploaded") 919 snapshot("checking was uploaded")
920 results.extend(input_api.canned_checks.CheckChangeWasUploaded( 920 results.extend(input_api.canned_checks.CheckChangeWasUploaded(
921 input_api, output_api)) 921 input_api, output_api))
922 snapshot("done") 922 snapshot("done")
923 return results 923 return results
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698