OLD | NEW |
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.1' | 9 __version__ = '1.0.1' |
10 | 10 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 """ | 623 """ |
624 presubmit_files = ListRelevantPresubmitFiles(change_info.FileList()) | 624 presubmit_files = ListRelevantPresubmitFiles(change_info.FileList()) |
625 if not presubmit_files and verbose: | 625 if not presubmit_files and verbose: |
626 print "Warning, no presubmit.py found." | 626 print "Warning, no presubmit.py found." |
627 results = [] | 627 results = [] |
628 executer = PresubmitExecuter(change_info, committing) | 628 executer = PresubmitExecuter(change_info, committing) |
629 for filename in presubmit_files: | 629 for filename in presubmit_files: |
630 if verbose: | 630 if verbose: |
631 print "Running %s" % filename | 631 print "Running %s" % filename |
632 # Accept CRLF presubmit script. | 632 # Accept CRLF presubmit script. |
633 presubmit_script = gcl.ReadFile(filename, 'Ur') | 633 presubmit_script = gcl.ReadFile(filename, 'rU') |
634 results += executer.ExecPresubmitScript(presubmit_script, filename) | 634 results += executer.ExecPresubmitScript(presubmit_script, filename) |
635 | 635 |
636 errors = [] | 636 errors = [] |
637 notifications = [] | 637 notifications = [] |
638 warnings = [] | 638 warnings = [] |
639 for result in results: | 639 for result in results: |
640 if not result.IsFatal() and not result.ShouldPrompt(): | 640 if not result.IsFatal() and not result.ShouldPrompt(): |
641 notifications.append(result) | 641 notifications.append(result) |
642 elif result.ShouldPrompt(): | 642 elif result.ShouldPrompt(): |
643 warnings.append(result) | 643 warnings.append(result) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 print "Found %d files." % len(files) | 700 print "Found %d files." % len(files) |
701 return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files), | 701 return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files), |
702 options.commit, | 702 options.commit, |
703 options.verbose, | 703 options.verbose, |
704 sys.stdout, | 704 sys.stdout, |
705 sys.stdin) | 705 sys.stdin) |
706 | 706 |
707 | 707 |
708 if __name__ == '__main__': | 708 if __name__ == '__main__': |
709 sys.exit(Main(sys.argv)) | 709 sys.exit(Main(sys.argv)) |
OLD | NEW |