Skip to content

Commit

Permalink
Updated get_version.
Browse files Browse the repository at this point in the history
  • Loading branch information
sixy6e committed Jun 8, 2016
1 parent 7d2bb13 commit 096c6e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
35 changes: 23 additions & 12 deletions gaip/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from __future__ import absolute_import, print_function

import re
import os
from os.path import dirname, isdir, join, exists
from subprocess import CalledProcessError, check_output

Expand All @@ -43,23 +44,33 @@ def get_version():
# (eg. "gaip-0.0.0-651-gcf335a9-dirty")
cmd = [
'git',
'--git-dir', git_dir,
'describe', '--tags', '--match', '[0-9]*', '--dirty'
]
try:
git_version = check_output(cmd).decode().strip()
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
components = git_version.split('-')
version = components.pop(0)

# Any other suffixes imply this is not a release: Append an internal build number
if components:
# <commit count>.<git hash>.<whether the working tree is dirty>
version += '+' + '.'.join(components)
with remember_cwd():
os.chdir(package_dir)
try:
git_version = check_output(cmd).decode().strip()
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')

components = git_version.split('-')
version = components.pop(0)

# Any other suffixes imply this is not a release: Append an internal build number
if components:
# <commit count>.<git hash>.<whether the working tree is dirty>
version += '+' + '.'.join(components)

return version


def remember_cwd():
current_dir = os.getcwd()
try:
yield
finally:
os.chdir(current_dir)


if __name__ == '__main__':
print(get_version())
1 change: 0 additions & 1 deletion workflow/nbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,6 @@ def run(self):
# TODO (a) retrieve software version from git once deployed
algorithm = {}
algorithm['algorithm_version'] = 2.0 # hardcode for now see TODO (a)
algorithm['software_version'] = gaip.get_version()
algorithm['software_repository'] = ('https://github.com/'
'GeoscienceAustralia/'
'ga-neo-landsat-processor.git')
Expand Down

0 comments on commit 096c6e1

Please sign in to comment.