Index: packager.py |
=================================================================== |
--- a/packager.py |
+++ b/packager.py |
@@ -19,20 +19,27 @@ def getDefaultFileName(baseDir, metadata |
def getMetadataPath(baseDir, type): |
return os.path.join(baseDir, 'metadata.%s' % type) |
def readMetadata(baseDir, type): |
return ChainedConfigParser(getMetadataPath(baseDir, type)) |
def getBuildNum(baseDir): |
try: |
- result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n']) |
- return re.sub(r'\D', '', result) |
- except: |
- return '0' |
+ from buildtools.ensure_dependencies import Mercurial, Git |
Sebastian Noack
2015/01/13 09:12:25
It seems that you only need Git.istype() and Mercu
Wladimir Palant
2015/01/13 12:56:53
As the OP explained in the pull request, these are
|
+ if Mercurial().istype(baseDir): |
+ result = subprocess.check_output(['hg', 'id', '-R', baseDir, '-n']) |
+ return re.sub(r'\D', '', result) |
+ elif Git().istype(baseDir): |
+ result = subprocess.check_output(['git', 'rev-list', 'HEAD'], cwd=baseDir) |
+ return len(result.splitlines()) |
+ except subprocess.CalledProcessError: |
+ pass |
+ |
+ return '0' |
def getBuildVersion(baseDir, metadata, releaseBuild, buildNum=None): |
version = metadata.get('general', 'version') |
if not releaseBuild: |
if buildNum == None: |
buildNum = getBuildNum(baseDir) |
buildNum = str(buildNum) |
if len(buildNum) > 0: |