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

Side by Side Diff: depot_tools/presubmit.py

Issue 99072: Add an optional flag to gcl.ReadFile() so that presubmit can support CRLF PRE... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/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 | « depot_tools/gcl.py ('k') | depot_tools/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 #!/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.1'
10 10
11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow 11 # TODO(joi) Add caching where appropriate/needed. The API is designed to allow
12 # caching (between all different invocations of presubmit scripts for a given 12 # caching (between all different invocations of presubmit scripts for a given
13 # change). We should add it as our presubmit scripts start feeling slow. 13 # change). We should add it as our presubmit scripts start feeling slow.
14 14
15 import cPickle # Exposed through the API. 15 import cPickle # Exposed through the API.
16 import cStringIO # Exposed through the API. 16 import cStringIO # Exposed through the API.
17 import exceptions 17 import exceptions
18 import fnmatch 18 import fnmatch
19 import glob 19 import glob
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 True if execution can continue, False if not. 622 True if execution can continue, False if not.
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 presubmit_script = gcl.ReadFile(filename) 632 # Accept CRLF presubmit script.
633 presubmit_script = gcl.ReadFile(filename, 'Ur')
633 results += executer.ExecPresubmitScript(presubmit_script, filename) 634 results += executer.ExecPresubmitScript(presubmit_script, filename)
634 635
635 errors = [] 636 errors = []
636 notifications = [] 637 notifications = []
637 warnings = [] 638 warnings = []
638 for result in results: 639 for result in results:
639 if not result.IsFatal() and not result.ShouldPrompt(): 640 if not result.IsFatal() and not result.ShouldPrompt():
640 notifications.append(result) 641 notifications.append(result)
641 elif result.ShouldPrompt(): 642 elif result.ShouldPrompt():
642 warnings.append(result) 643 warnings.append(result)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 print "Found %d files." % len(files) 700 print "Found %d files." % len(files)
700 return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files), 701 return DoPresubmitChecks(gcl.ChangeInfo(name='temp', files=files),
701 options.commit, 702 options.commit,
702 options.verbose, 703 options.verbose,
703 sys.stdout, 704 sys.stdout,
704 sys.stdin) 705 sys.stdin)
705 706
706 707
707 if __name__ == '__main__': 708 if __name__ == '__main__':
708 sys.exit(Main(sys.argv)) 709 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « depot_tools/gcl.py ('k') | depot_tools/tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698