Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: packager.py

Issue 29904555: Issue 7004 - Actually return git's result (Closed)
Patch Set: Created Oct. 8, 2018, 1:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« 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 # This Source Code Form is subject to the terms of the Mozilla Public 1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 4
5 # Note: These are the base functions common to all packagers, the actual 5 # Note: These are the base functions common to all packagers, the actual
6 # packagers are implemented in packagerChrome and packagerEdge. 6 # packagers are implemented in packagerChrome and packagerEdge.
7 7
8 import sys 8 import sys
9 import os 9 import os
10 import re 10 import re
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 return parser 65 return parser
66 66
67 67
68 def getBuildNum(baseDir): 68 def getBuildNum(baseDir):
69 try: 69 try:
70 from buildtools.ensure_dependencies import Mercurial, Git 70 from buildtools.ensure_dependencies import Mercurial, Git
71 if Mercurial().istype(baseDir): 71 if Mercurial().istype(baseDir):
72 result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n']) 72 result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n'])
73 return re.sub(r'\D', '', result) 73 return re.sub(r'\D', '', result)
74 elif Git().istype(baseDir): 74 elif Git().istype(baseDir):
75 result = subprocess.check_output(['git', 'rev-list', 'HEAD'], cwd=ba seDir) 75 result = subprocess.check_output(
76 return str(len(result.splitlines())) 76 ['git', 'rev-list', '--count', '--branches', '--tags'],
77 cwd=baseDir,
78 )
79 return result.strip()
Sebastian Noack 2018/10/08 14:01:04 Perhaps we can unify the code paths here: if Me
tlucas 2018/10/08 14:19:42 I see how this would improve the code, but since w
Sebastian Noack 2018/10/08 14:26:06 I think the requested change is trivial, and makes
77 except subprocess.CalledProcessError: 80 except subprocess.CalledProcessError:
78 pass 81 pass
79 82
80 return '0' 83 return '0'
81 84
82 85
83 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None): 86 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None):
84 version = metadata.get('general', 'version') 87 version = metadata.get('general', 'version')
85 if not releaseBuild: 88 if not releaseBuild:
86 if buildNum == None: 89 if buildNum == None:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 167
165 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED): 168 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
166 with zipfile.ZipFile(outFile, 'w', compression) as zf: 169 with zipfile.ZipFile(outFile, 'w', compression) as zf:
167 for name in sorted(self, key=sortKey): 170 for name in sorted(self, key=sortKey):
168 zf.writestr(name, self[name]) 171 zf.writestr(name, self[name])
169 172
170 def zipToString(self, sortKey=None): 173 def zipToString(self, sortKey=None):
171 buffer = StringIO() 174 buffer = StringIO()
172 self.zip(buffer, sortKey=sortKey) 175 self.zip(buffer, sortKey=sortKey)
173 return buffer.getvalue() 176 return buffer.getvalue()
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