| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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() |
| LEFT | RIGHT |