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

Side by Side Diff: runtime/tools/make_version.py

Issue 11236034: Fix version script for git repos that are not git-svn. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 # 4 #
5 # This python script creates a version string in a C++ file. 5 # This python script creates a version string in a C++ file.
6 6
7 import os 7 import os
8 import sys 8 import sys
9 import subprocess 9 import subprocess
10 import platform 10 import platform
(...skipping 17 matching lines...) Expand all
28 debugLog("Got result: %s" % result) 28 debugLog("Got result: %s" % result)
29 return result 29 return result
30 30
31 def getRevision(): 31 def getRevision():
32 debugLog("Getting revision") 32 debugLog("Getting revision")
33 is_svn = True 33 is_svn = True
34 if os.path.exists('.svn'): 34 if os.path.exists('.svn'):
35 debugLog("Using svn to get revision") 35 debugLog("Using svn to get revision")
36 cmd = ['svn', 'info'] 36 cmd = ['svn', 'info']
37 else: 37 else:
38 debugLog("Using git svn to get revision") 38 git_proc = subprocess.Popen(
Ivan Posva 2012/10/26 02:57:06 I know this was already an issue previously: What
Mads Ager (google) 2012/10/26 06:26:47 Yeah, I actually did remove a try: block from here
39 cmd = ['git', 'svn', 'info'] 39 ['git', 'branch', '-r'],
40 try: 40 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
41 debugLog("Running command to get revision: %s" % cmd) 41 if 'git-svn' in git_proc.communicate()[0]:
42 proc = subprocess.Popen(cmd, 42 debugLog("Using git svn to get revision")
43 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 43 cmd = ['git', 'svn', 'info']
44 revision = proc.communicate()[0].split('\n')[4].split(' ')[1] 44 else:
45 debugLog("Got revision: %s" % revision) 45 # Cannot get revision because we are not in svn or
46 return revision 46 # git svn checkout.
47 except Exception: 47 debugLog("Could not get revision: not an svn or git-svn checkout?")
48 # If we can't get any revision info (due to lack of tooling) return ''. 48 return ''
49 return '' 49 debugLog("Running command to get revision: %s" % cmd)
50 50 proc = subprocess.Popen(cmd,
51 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
52 revision = proc.communicate()[0].split('\n')[4].split(' ')[1]
53 debugLog("Got revision: %s" % revision)
54 return revision
51 55
52 def makeVersionString(version_file): 56 def makeVersionString(version_file):
53 id = platform.system() 57 id = platform.system()
54 if id == 'Windows' or id == 'Microsoft': 58 if id == 'Windows' or id == 'Microsoft':
55 return '0.0.0.0' 59 return '0.0.0.0'
56 major = getVersionPart(version_file, 'MAJOR') 60 major = getVersionPart(version_file, 'MAJOR')
57 minor = getVersionPart(version_file, 'MINOR') 61 minor = getVersionPart(version_file, 'MINOR')
58 build = getVersionPart(version_file, 'BUILD') 62 build = getVersionPart(version_file, 'BUILD')
59 patch = getVersionPart(version_file, 'PATCH') 63 patch = getVersionPart(version_file, 'PATCH')
60 revision = getRevision() 64 revision = getRevision()
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 sys.stderr.write('make_version.py exception\n') 123 sys.stderr.write('make_version.py exception\n')
120 sys.stderr.write(str(inst)) 124 sys.stderr.write(str(inst))
121 sys.stderr.write('\n') 125 sys.stderr.write('\n')
122 return -1 126 return -1
123 127
124 if __name__ == '__main__': 128 if __name__ == '__main__':
125 debugLog('starting make_version.py') 129 debugLog('starting make_version.py')
126 exit_code = main(sys.argv) 130 exit_code = main(sys.argv)
127 debugLog('exiting make_version.py (exit code: %s)' % exit_code) 131 debugLog('exiting make_version.py (exit code: %s)' % exit_code)
128 sys.exit(exit_code) 132 sys.exit(exit_code)
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