master/buildbot/__init__.py
author ffxbld
Thu, 08 Jan 2015 23:25:35 -0500
branchproduction-0.8
changeset 1221 3d67bdd68e436955cba59a437572dbf3e251fe33
parent 114 161d0a80925c11e428fe3febe7f841b4befa423f
permissions -rw-r--r--
Added FIREFOX_35_0_RELEASE FIREFOX_35_0_BUILD3 tag(s) for changeset production-0.8. DONTBUILD CLOSED TREE a=release

# strategy:
#
# if there is a VERSION file, use its contents. otherwise, call git to
# get a version string. if that also fails, use 'latest'.
#
import os

version = "latest"

try:
    fn = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')
    version = open(fn).read().strip()
except IOError:
    raise RuntimeError("cannot find VERSION file")

# get the mozilla version info from hg
version_hg = ''
try:
    from subprocess import Popen, PIPE, STDOUT
    p = Popen(['hg', 'ident', '-i', '-b'], stdout=PIPE, stderr=STDOUT)
    out = p.communicate()[0]

    if (not p.returncode) and out:
        version_hg = out.strip().replace(' ', '-')
except OSError:
    pass

if version_hg:
    version += '-hg-' + version_hg

# remainder kept here to avoid merge conflicts with upstream
try:
    pass
except IOError:
    from subprocess import Popen, PIPE, STDOUT
    import re

    VERSION_MATCH = re.compile(r'\d+\.\d+\.\d+(\w|-)*')

    try:
        p = Popen(['git', 'describe', '--tags', '--always'], stdout=PIPE, stderr=STDOUT)
        out = p.communicate()[0]

        if (not p.returncode) and out:
            v = VERSION_MATCH.search(out)
            if v:
                version = v.group()
    except OSError:
        pass