Skip to content

Commit 096c6e1

Browse files
committed
Updated get_version.
1 parent 7d2bb13 commit 096c6e1

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

gaip/version.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__ import absolute_import, print_function
2020

2121
import re
22+
import os
2223
from os.path import dirname, isdir, join, exists
2324
from subprocess import CalledProcessError, check_output
2425

@@ -43,23 +44,33 @@ def get_version():
4344
# (eg. "gaip-0.0.0-651-gcf335a9-dirty")
4445
cmd = [
4546
'git',
46-
'--git-dir', git_dir,
4747
'describe', '--tags', '--match', '[0-9]*', '--dirty'
4848
]
49-
try:
50-
git_version = check_output(cmd).decode().strip()
51-
except CalledProcessError:
52-
raise RuntimeError('Unable to get version number from git tags')
53-
components = git_version.split('-')
54-
version = components.pop(0)
55-
56-
# Any other suffixes imply this is not a release: Append an internal build number
57-
if components:
58-
# <commit count>.<git hash>.<whether the working tree is dirty>
59-
version += '+' + '.'.join(components)
49+
with remember_cwd():
50+
os.chdir(package_dir)
51+
try:
52+
git_version = check_output(cmd).decode().strip()
53+
except CalledProcessError:
54+
raise RuntimeError('Unable to get version number from git tags')
55+
56+
components = git_version.split('-')
57+
version = components.pop(0)
58+
59+
# Any other suffixes imply this is not a release: Append an internal build number
60+
if components:
61+
# <commit count>.<git hash>.<whether the working tree is dirty>
62+
version += '+' + '.'.join(components)
6063

6164
return version
6265

6366

67+
def remember_cwd():
68+
current_dir = os.getcwd()
69+
try:
70+
yield
71+
finally:
72+
os.chdir(current_dir)
73+
74+
6475
if __name__ == '__main__':
6576
print(get_version())

workflow/nbar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,6 @@ def run(self):
17231723
# TODO (a) retrieve software version from git once deployed
17241724
algorithm = {}
17251725
algorithm['algorithm_version'] = 2.0 # hardcode for now see TODO (a)
1726-
algorithm['software_version'] = gaip.get_version()
17271726
algorithm['software_repository'] = ('https://github.com/'
17281727
'GeoscienceAustralia/'
17291728
'ga-neo-landsat-processor.git')

0 commit comments

Comments
 (0)