diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-01-30 15:43:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-01-30 15:43:59 +0000 |
| commit | 6449851a969f356e0c8d13bfbcefd6b2c21fb350 (patch) | |
| tree | 3a6c580f2557efffa78e3ef9cf949b4d9d81401c /openstackclient | |
| parent | 5a9fbc5fcad53cb3dba469289cafda4ca6446049 (diff) | |
| parent | 67bba28ed1d16300fb23cf3466a503d3fcf7d3b4 (diff) | |
| download | python-openstackclient-6449851a969f356e0c8d13bfbcefd6b2c21fb350.tar.gz | |
Merge "Use install_venv_common.py from oslo."
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/openstack/common/setup.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/openstackclient/openstack/common/setup.py b/openstackclient/openstack/common/setup.py index 53af7203..fb187fff 100644 --- a/openstackclient/openstack/common/setup.py +++ b/openstackclient/openstack/common/setup.py @@ -258,6 +258,22 @@ def get_cmdclass(): return cmdclass +def _get_revno(): + """Return the number of commits since the most recent tag. + + We use git-describe to find this out, but if there are no + tags then we fall back to counting commits since the beginning + of time. + """ + describe = _run_shell_command("git describe --always") + if "-" in describe: + return describe.rsplit("-", 2)[-2] + + # no tags found + revlist = _run_shell_command("git rev-list --abbrev-commit HEAD") + return len(revlist.splitlines()) + + def get_version_from_git(pre_version): """Return a version which is equal to the tag that's on the current revision if there is one, or tag plus number of additional revisions @@ -271,9 +287,7 @@ def get_version_from_git(pre_version): throw_on_error=True).replace('-', '.') except Exception: sha = _run_shell_command("git log -n1 --pretty=format:%h") - describe = _run_shell_command("git describe --always") - revno = describe.rsplit("-", 2)[-2] - return "%s.a%s.g%s" % (pre_version, revno, sha) + return "%s.a%s.g%s" % (pre_version, _get_revno(), sha) else: return _run_shell_command( "git describe --always").replace('-', '.') |
