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

Unified Diff: packager.py

Issue 6562202978877440: Issue 1778 - Generate proper build numbers when working with Git repositories (Closed)
Patch Set: Created Jan. 12, 2015, 6:43 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld