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

Delta Between Two Patch Sets: packager.py

Issue 29904555: Issue 7004 - Actually return git's result (Closed)
Left Patch Set: Created Oct. 8, 2018, 1:22 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 75 result = subprocess.check_output(
76 ['git', 'rev-list', '--count', '--branches', '--tags'], 76 ['git', 'rev-list', '--count', '--branches', '--tags'],
77 cwd=baseDir, 77 cwd=baseDir,
78 ) 78 )
79 return re.sub(r'\D', '', result) 79 return result.strip()
Sebastian Noack 2018/10/08 13:28:25 Wouldn't strip() do?
tlucas 2018/10/08 13:35:28 It does :) Done.
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
80 except subprocess.CalledProcessError: 80 except subprocess.CalledProcessError:
81 pass 81 pass
82 82
83 return '0' 83 return '0'
84 84
85 85
86 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None): 86 def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None):
87 version = metadata.get('general', 'version') 87 version = metadata.get('general', 'version')
88 if not releaseBuild: 88 if not releaseBuild:
89 if buildNum == None: 89 if buildNum == None:
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED): 168 def zip(self, outFile, sortKey=None, compression=zipfile.ZIP_DEFLATED):
169 with zipfile.ZipFile(outFile, 'w', compression) as zf: 169 with zipfile.ZipFile(outFile, 'w', compression) as zf:
170 for name in sorted(self, key=sortKey): 170 for name in sorted(self, key=sortKey):
171 zf.writestr(name, self[name]) 171 zf.writestr(name, self[name])
172 172
173 def zipToString(self, sortKey=None): 173 def zipToString(self, sortKey=None):
174 buffer = StringIO() 174 buffer = StringIO()
175 self.zip(buffer, sortKey=sortKey) 175 self.zip(buffer, sortKey=sortKey)
176 return buffer.getvalue() 176 return buffer.getvalue()
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld