summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Peeler <jpeeler@redhat.com>2012-09-28 20:00:34 -0400
committerJeff Peeler <jpeeler@redhat.com>2012-10-09 17:05:54 +0100
commit2e3bdd951028f8d0b201b9ddb2553b194a1b0941 (patch)
tree87e5b487603363e8359fe487dd52ce07d009b7d8
parent9cf1c6f269ac10c2493653c646bbef9271cf7122 (diff)
downloadheat-2e3bdd951028f8d0b201b9ddb2553b194a1b0941.tar.gz
Fix versioning code
Removed cruft from OpenStack common versioning code that was removed. Added optional git SHA information if module is available. The intent is to have the additional git revision reported only when FINAL is set to False. Change-Id: Iae94b84027e7428cd394726e07845d2bad631586 Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
-rw-r--r--heat/service.py2
-rw-r--r--heat/version.py53
-rwxr-xr-xsetup.py4
3 files changed, 39 insertions, 20 deletions
diff --git a/heat/service.py b/heat/service.py
index 4ea5ba0d2..555244404 100644
--- a/heat/service.py
+++ b/heat/service.py
@@ -116,7 +116,7 @@ class Service(object):
self.timers = []
def start(self):
- vcs_string = version.version_string_with_vcs()
+ vcs_string = version.version_string(type='long')
LOG.info(_('Starting %(topic)s node (version %(vcs_string)s)'),
{'topic': self.topic, 'vcs_string': vcs_string})
# TODO do we need this ? -> utils.cleanup_file_locks()
diff --git a/heat/version.py b/heat/version.py
index 82f0aaa12..2c75971ae 100644
--- a/heat/version.py
+++ b/heat/version.py
@@ -13,33 +13,52 @@
# License for the specific language governing permissions and limitations
# under the License.
+
try:
- from heat.vcsversion import version_info
+ import git
except ImportError:
- version_info = {'branch_nick': u'LOCALBRANCH',
- 'revision_id': 'LOCALREVISION',
- 'revno': 0}
+ git = None
-HEAT_VERSION = ['7']
-REVISION = HEAT_VERSION
+try:
+ from heat.vcsversion import version_info
+except ImportError:
+ version_info = {'sha': ''}
+HEAT_VERSION = '7'
FINAL = False # This becomes true at Release Candidate time
-def canonical_version_string():
- return '.'.join(filter(None, HEAT_VERSION))
+def get_git_sha():
+ if not git:
+ return version_info['sha']
+
+ try:
+ repo = git.Repo('.')
+ except InvalidGitRepositoryError:
+ return version_info['sha']
+ return repo.head.commit.hexsha
-def version_string():
- if FINAL:
- return canonical_version_string()
- else:
- return '%s-dev' % (canonical_version_string(),)
+def write_git_sha():
+ if not git:
+ return
+ sha = get_git_sha()
-def vcs_version_string():
- return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
+ if sha:
+ with open('heat/vcsversion.py', 'w') as version_file:
+ version_file.write("""
+# This file is automatically generated by heat's setup.py, so don't edit it. :)
+version_info = {
+ 'sha': '%s'
+}
+""" % (sha))
-def version_string_with_vcs():
- return "%s-%s" % (canonical_version_string(), vcs_version_string())
+def version_string(type='short'):
+ version = HEAT_VERSION
+ if not FINAL:
+ version += '-dev ' + get_git_sha()
+ elif type != 'short':
+ version += ' ' + get_git_sha()
+ return version
diff --git a/setup.py b/setup.py
index 72b1d9568..4503489e0 100755
--- a/setup.py
+++ b/setup.py
@@ -21,12 +21,12 @@ import setuptools
from heat.openstack.common import setup
-# import this after write_vcsversion because version imports vcsversion
from heat import version
+version.write_git_sha()
setuptools.setup(
name='heat',
- version=version.canonical_version_string(),
+ version=version.HEAT_VERSION,
description='The heat project provides services for provisioning '
'virtual machines',
license='Apache License (2.0)',