Example #1
0
def getBuildNum(baseDir):
    try:
        from buildtools.ensure_dependencies import Mercurial, Git
        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 str(len(result.splitlines()))
    except subprocess.CalledProcessError:
        pass

    return '0'
Example #2
0
def getBuildNum(baseDir):
    try:
        from buildtools.ensure_dependencies import Mercurial, Git
        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', '--count', '--branches', '--tags'],
                cwd=baseDir,
            )
            return result.strip()
    except subprocess.CalledProcessError:
        pass

    return '0'