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

Side by Side Diff: build/util/lastchange.py

Issue 6308016: lastchange: don't use git rev-parse output when it fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 """ 6 """
7 lastchange.py -- Chromium revision fetching utility. 7 lastchange.py -- Chromium revision fetching utility.
8 """ 8 """
9 9
10 import optparse 10 import optparse
(...skipping 23 matching lines...) Expand all
34 command = ['git', 'rev-parse', 'HEAD'] 34 command = ['git', 'rev-parse', 'HEAD']
35 if sys.platform in ('cygwin', 'win32'): 35 if sys.platform in ('cygwin', 'win32'):
36 command = ['sh', '-c', ' '.join(command)] 36 command = ['sh', '-c', ' '.join(command)]
37 try: 37 try:
38 proc = subprocess.Popen(command, 38 proc = subprocess.Popen(command,
39 stdout=subprocess.PIPE, 39 stdout=subprocess.PIPE,
40 stderr=subprocess.PIPE, 40 stderr=subprocess.PIPE,
41 cwd=directory) 41 cwd=directory)
42 except OSError: 42 except OSError:
43 return None 43 return None
44 return VersionInfo('git', 'git', proc.stdout.read().strip()[:7]) 44 output = proc.communicate()[0].strip()
45 if proc.returncode == 0 and output:
46 return VersionInfo('git', 'git', output[:7])
47 return None
45 48
46 49
47 def FetchSVNRevision(directory): 50 def FetchSVNRevision(directory):
48 """ 51 """
49 Fetch the Subversion branch and revision for the a given directory. 52 Fetch the Subversion branch and revision for the a given directory.
50 53
51 Errors are swallowed. 54 Errors are swallowed.
52 55
53 Returns: 56 Returns:
54 a VersionInfo object or None on error. 57 a VersionInfo object or None on error.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 if out_file: 148 if out_file:
146 WriteIfChanged(out_file, contents) 149 WriteIfChanged(out_file, contents)
147 else: 150 else:
148 sys.stdout.write(contents) 151 sys.stdout.write(contents)
149 152
150 return 0 153 return 0
151 154
152 155
153 if __name__ == '__main__': 156 if __name__ == '__main__':
154 sys.exit(main()) 157 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698