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

Side by Side Diff: tools/presubmit.py

Issue 837503003: Check author of a CL agaist the AUTHORS file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2012 the V8 project authors. All rights reserved. 3 # Copyright 2012 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 code = subprocess.call( 431 code = subprocess.call(
432 [sys.executable, join(workspace, "tools", "check-name-clashes.py")]) 432 [sys.executable, join(workspace, "tools", "check-name-clashes.py")])
433 return code == 0 433 return code == 0
434 434
435 435
436 def CheckExternalReferenceRegistration(workspace): 436 def CheckExternalReferenceRegistration(workspace):
437 code = subprocess.call( 437 code = subprocess.call(
438 [sys.executable, join(workspace, "tools", "external-reference-check.py")]) 438 [sys.executable, join(workspace, "tools", "external-reference-check.py")])
439 return code == 0 439 return code == 0
440 440
441 def CheckAuthorizedAuthor(input_api, output_api):
442 """For non-googler/chromites committers, verify the author's email address is
443 in AUTHORS.
444 """
445 # TODO(maruel): Add it to input_api?
446 import fnmatch
447
448 author = input_api.change.author_email
449 if not author:
450 input_api.logging.info('No author, skipping AUTHOR check')
451 return []
452 authors_path = input_api.os_path.join(
453 input_api.PresubmitLocalPath(), 'AUTHORS')
454 valid_authors = (
455 input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line)
456 for line in open(authors_path))
457 valid_authors = [item.group(1).lower() for item in valid_authors if item]
458 if not any(fnmatch.fnmatch(author.lower(), valid) for valid in valid_authors):
459 input_api.logging.info('Valid authors are %s', ', '.join(valid_authors))
460 return [output_api.PresubmitPromptWarning(
Michael Achenbach 2015/01/15 12:29:22 I assume a warning is enough to bail out?
marja 2015/01/15 12:37:39 It's a prompt warning, so it'll prompt the user an
461 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
462 '\n'
463 'http://www.chromium.org/developers/contributing-code and read the '
464 '"Legal" section\n'
465 'If you are a chromite, verify the contributor signed the CLA.') %
466 author)]
467 return []
441 468
442 def GetOptions(): 469 def GetOptions():
443 result = optparse.OptionParser() 470 result = optparse.OptionParser()
444 result.add_option('--no-lint', help="Do not run cpplint", default=False, 471 result.add_option('--no-lint', help="Do not run cpplint", default=False,
445 action="store_true") 472 action="store_true")
446 return result 473 return result
447 474
448 475
449 def Main(): 476 def Main():
450 workspace = abspath(join(dirname(sys.argv[0]), '..')) 477 workspace = abspath(join(dirname(sys.argv[0]), '..'))
451 parser = GetOptions() 478 parser = GetOptions()
452 (options, args) = parser.parse_args() 479 (options, args) = parser.parse_args()
453 success = True 480 success = True
454 print "Running C++ lint check..." 481 print "Running C++ lint check..."
455 if not options.no_lint: 482 if not options.no_lint:
456 success = CppLintProcessor().Run(workspace) and success 483 success = CppLintProcessor().Run(workspace) and success
457 print "Running copyright header, trailing whitespaces and " \ 484 print "Running copyright header, trailing whitespaces and " \
458 "two empty lines between declarations check..." 485 "two empty lines between declarations check..."
459 success = SourceProcessor().Run(workspace) and success 486 success = SourceProcessor().Run(workspace) and success
460 success = CheckRuntimeVsNativesNameClashes(workspace) and success 487 success = CheckRuntimeVsNativesNameClashes(workspace) and success
461 success = CheckExternalReferenceRegistration(workspace) and success 488 success = CheckExternalReferenceRegistration(workspace) and success
462 if success: 489 if success:
463 return 0 490 return 0
464 else: 491 else:
465 return 1 492 return 1
466 493
467 494
468 if __name__ == '__main__': 495 if __name__ == '__main__':
469 sys.exit(Main()) 496 sys.exit(Main())
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698