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

Side by Side Diff: presubmit.py

Issue 93108: Fix gclient on posix platforms.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/tools/depot_tools/
Patch Set: Created 11 years, 8 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 | « gclient ('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/python 1 #!/usr/bin/python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.0' 9 __version__ = '1.0'
10 10
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 else: 594 else:
595 result = () # no error since the script doesn't care about current event. 595 result = () # no error since the script doesn't care about current event.
596 596
597 return result 597 return result
598 598
599 599
600 def DoPresubmitChecks(change_info, 600 def DoPresubmitChecks(change_info,
601 committing, 601 committing,
602 verbose, 602 verbose,
603 output_stream, 603 output_stream,
604 input_stream, 604 input_stream):
605 default_presubmit):
606 """Runs all presubmit checks that apply to the files in the change. 605 """Runs all presubmit checks that apply to the files in the change.
607 606
608 This finds all PRESUBMIT.py files in directories enclosing the files in the 607 This finds all PRESUBMIT.py files in directories enclosing the files in the
609 change (up to the repository root) and calls the relevant entrypoint function 608 change (up to the repository root) and calls the relevant entrypoint function
610 depending on whether the change is being committed or uploaded. 609 depending on whether the change is being committed or uploaded.
611 610
612 Prints errors, warnings and notifications. Prompts the user for warnings 611 Prints errors, warnings and notifications. Prompts the user for warnings
613 when needed. 612 when needed.
614 613
615 Args: 614 Args:
616 change_info: The ChangeInfo object for the change. 615 change_info: The ChangeInfo object for the change.
617 committing: True if 'gcl commit' is running, False if 'gcl upload' is. 616 committing: True if 'gcl commit' is running, False if 'gcl upload' is.
618 verbose: Prints debug info. 617 verbose: Prints debug info.
619 output_stream: A stream to write output from presubmit tests to. 618 output_stream: A stream to write output from presubmit tests to.
620 input_stream: A stream to read input from the user. 619 input_stream: A stream to read input from the user.
621 default_presubmit: A default presubmit script to execute in any case.
622 620
623 Return: 621 Return:
624 True if execution can continue, False if not. 622 True if execution can continue, False if not.
625 """ 623 """
626 presubmit_files = ListRelevantPresubmitFiles(change_info.FileList()) 624 presubmit_files = ListRelevantPresubmitFiles(change_info.FileList())
627 if not presubmit_files and verbose: 625 if not presubmit_files and verbose:
628 print "Warning, no presubmit.py found." 626 print "Warning, no presubmit.py found."
629 results = [] 627 results = []
630 executer = PresubmitExecuter(change_info, committing) 628 executer = PresubmitExecuter(change_info, committing)
631 if default_presubmit:
632 if verbose:
633 print "Running default presubmit script"
634 results += executer.ExecPresubmitScript(default_presubmit, 'PRESUBMIT.py')
635 for filename in presubmit_files: 629 for filename in presubmit_files:
636 if verbose: 630 if verbose:
637 print "Running %s" % filename 631 print "Running %s" % filename
638 presubmit_script = gcl.ReadFile(filename) 632 presubmit_script = gcl.ReadFile(filename)
639 results += executer.ExecPresubmitScript(presubmit_script, filename) 633 results += executer.ExecPresubmitScript(presubmit_script, filename)
640 634
641 errors = [] 635 errors = []
642 notifications = [] 636 notifications = []
643 warnings = [] 637 warnings = []
644 for result in results: 638 for result in results:
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 parser.add_option("-c", "--commit", action="store_true", 690 parser.add_option("-c", "--commit", action="store_true",
697 help="Use commit instead of upload checks") 691 help="Use commit instead of upload checks")
698 parser.add_option("-r", "--recursive", action="store_true", 692 parser.add_option("-r", "--recursive", action="store_true",
699 help="Act recursively") 693 help="Act recursively")
700 parser.add_option("-v", "--verbose", action="store_true", 694 parser.add_option("-v", "--verbose", action="store_true",
701 help="Verbose output") 695 help="Verbose output")
702 options, args = parser.parse_args(argv[1:]) 696 options, args = parser.parse_args(argv[1:])
703 files = ParseFiles(args, options.recursive) 697 files = ParseFiles(args, options.recursive)
704 if options.verbose: 698 if options.verbose:
705 print "Found %d files." % len(files) 699 print "Found %d files." % len(files)
706 return not DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files), 700 return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files),
707 options.commit, 701 options.commit,
708 options.verbose, 702 options.verbose,
709 sys.stdout, 703 sys.stdout,
710 sys.stdin, 704 sys.stdin)
711 default_presubmit=None)
712 705
713 706
714 if __name__ == '__main__': 707 if __name__ == '__main__':
715 sys.exit(Main(sys.argv)) 708 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « gclient ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698