OLD | NEW |
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 Loading... |
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 ['git', 'rev-list', '--count', '--branches', '--tags'], |
| 77 cwd=baseDir, |
| 78 ) |
76 return str(len(result.splitlines())) | 79 return str(len(result.splitlines())) |
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: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() |
OLD | NEW |