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

Side by Side Diff: presubmit_support.py

Issue 125051: Fix gcl breakage. (Closed)
Patch Set: Created 11 years, 6 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 | « gcl.py ('k') | tests/gcl_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.3.2' 9 __version__ = '1.3.2'
10 10
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 self._name = change_info.name 509 self._name = change_info.name
510 self._full_description = change_info.description 510 self._full_description = change_info.description
511 self._repository_root = change_info.GetLocalRoot() 511 self._repository_root = change_info.GetLocalRoot()
512 self.issue = change_info.issue 512 self.issue = change_info.issue
513 self.patchset = change_info.patchset 513 self.patchset = change_info.patchset
514 514
515 # From the description text, build up a dictionary of key/value pairs 515 # From the description text, build up a dictionary of key/value pairs
516 # plus the description minus all key/value or "tag" lines. 516 # plus the description minus all key/value or "tag" lines.
517 self._description_without_tags = [] 517 self._description_without_tags = []
518 self.tags = {} 518 self.tags = {}
519 for line in change_info.description.splitlines(): 519 for line in self._full_description.splitlines():
520 m = self._tag_line_re.match(line) 520 m = self._tag_line_re.match(line)
521 if m: 521 if m:
522 self.tags[m.group('key')] = m.group('value') 522 self.tags[m.group('key')] = m.group('value')
523 else: 523 else:
524 self._description_without_tags.append(line) 524 self._description_without_tags.append(line)
525 525
526 # Change back to text and remove whitespace at end. 526 # Change back to text and remove whitespace at end.
527 self._description_without_tags = '\n'.join(self._description_without_tags) 527 self._description_without_tags = '\n'.join(self._description_without_tags)
528 self._description_without_tags = self._description_without_tags.rstrip() 528 self._description_without_tags = self._description_without_tags.rstrip()
529 529
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 verbose: Prints debug info. 719 verbose: Prints debug info.
720 output_stream: A stream to write output from presubmit tests to. 720 output_stream: A stream to write output from presubmit tests to.
721 input_stream: A stream to read input from the user. 721 input_stream: A stream to read input from the user.
722 default_presubmit: A default presubmit script to execute in any case. 722 default_presubmit: A default presubmit script to execute in any case.
723 may_prompt: Enable (y/n) questions on warning or error. 723 may_prompt: Enable (y/n) questions on warning or error.
724 724
725 Return: 725 Return:
726 True if execution can continue, False if not. 726 True if execution can continue, False if not.
727 """ 727 """
728 presubmit_files = ListRelevantPresubmitFiles(change_info.GetFileNames(), 728 presubmit_files = ListRelevantPresubmitFiles(change_info.GetFileNames(),
729 change_info.local_root) 729 change_info.GetLocalRoot())
730 if not presubmit_files and verbose: 730 if not presubmit_files and verbose:
731 output_stream.write("Warning, no presubmit.py found.\n") 731 output_stream.write("Warning, no presubmit.py found.\n")
732 results = [] 732 results = []
733 executer = PresubmitExecuter(change_info, committing) 733 executer = PresubmitExecuter(change_info, committing)
734 if default_presubmit: 734 if default_presubmit:
735 if verbose: 735 if verbose:
736 output_stream.write("Running default presubmit script.\n") 736 output_stream.write("Running default presubmit script.\n")
737 fake_path = os.path.join(change_info.local_root, 'PRESUBMIT.py') 737 fake_path = os.path.join(change_info.GetLocalRoot(), 'PRESUBMIT.py')
738 results += executer.ExecPresubmitScript(default_presubmit, fake_path) 738 results += executer.ExecPresubmitScript(default_presubmit, fake_path)
739 for filename in presubmit_files: 739 for filename in presubmit_files:
740 filename = os.path.abspath(filename) 740 filename = os.path.abspath(filename)
741 if verbose: 741 if verbose:
742 output_stream.write("Running %s\n" % filename) 742 output_stream.write("Running %s\n" % filename)
743 # Accept CRLF presubmit script. 743 # Accept CRLF presubmit script.
744 presubmit_script = gcl.ReadFile(filename, 'rU') 744 presubmit_script = gcl.ReadFile(filename, 'rU')
745 results += executer.ExecPresubmitScript(presubmit_script, filename) 745 results += executer.ExecPresubmitScript(presubmit_script, filename)
746 746
747 errors = [] 747 errors = []
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 parser.add_option("-c", "--commit", action="store_true", 802 parser.add_option("-c", "--commit", action="store_true",
803 help="Use commit instead of upload checks") 803 help="Use commit instead of upload checks")
804 parser.add_option("-r", "--recursive", action="store_true", 804 parser.add_option("-r", "--recursive", action="store_true",
805 help="Act recursively") 805 help="Act recursively")
806 parser.add_option("-v", "--verbose", action="store_true", 806 parser.add_option("-v", "--verbose", action="store_true",
807 help="Verbose output") 807 help="Verbose output")
808 options, args = parser.parse_args(argv[1:]) 808 options, args = parser.parse_args(argv[1:])
809 files = ParseFiles(args, options.recursive) 809 files = ParseFiles(args, options.recursive)
810 if options.verbose: 810 if options.verbose:
811 print "Found %d files." % len(files) 811 print "Found %d files." % len(files)
812 return not DoPresubmitChecks(gcl.ChangeInfo('No name', 0, 0, '', files), 812 return not DoPresubmitChecks(gcl.ChangeInfo('No name', 0, 0, '', files,
813 gcl.GetRepositoryRoot()),
813 options.commit, 814 options.commit,
814 options.verbose, 815 options.verbose,
815 sys.stdout, 816 sys.stdout,
816 sys.stdin, 817 sys.stdin,
817 None, 818 None,
818 False) 819 False)
819 820
820 821
821 if __name__ == '__main__': 822 if __name__ == '__main__':
822 sys.exit(Main(sys.argv)) 823 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698