Index: .gitignore =================================================================== diff -u -r74148a933061455b10101e4eb58144ca9d2f3cd2 -r01777f61bd58d75904abc7f29033813f0e947736 --- .gitignore (.../.gitignore) (revision 74148a933061455b10101e4eb58144ca9d2f3cd2) +++ .gitignore (.../.gitignore) (revision 01777f61bd58d75904abc7f29033813f0e947736) @@ -22,5 +22,6 @@ docs/source/dialin.utils.rst docs/source/dialin.squish.rst docs/source/modules.rst +docs/source/dialin.common.rst *.swp Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -rd4c07268dfcb79727bf9516db309944635895a0b -r01777f61bd58d75904abc7f29033813f0e947736 --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision d4c07268dfcb79727bf9516db309944635895a0b) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 01777f61bd58d75904abc7f29033813f0e947736) @@ -29,6 +29,7 @@ DenaliCanMessenger, DenaliChannels) from ..utils.base import _AbstractSubSystem, _publish, _LogManager +from .constants import NO_RESET class HD(_AbstractSubSystem): Index: dialin/version.py =================================================================== diff -u -ra89308cbb06b9d2052fe3d1b4ed210a03036a021 -r01777f61bd58d75904abc7f29033813f0e947736 --- dialin/version.py (.../version.py) (revision a89308cbb06b9d2052fe3d1b4ed210a03036a021) +++ dialin/version.py (.../version.py) (revision 01777f61bd58d75904abc7f29033813f0e947736) @@ -15,28 +15,55 @@ ############################################################################ import subprocess +VERSION = "0.6.0" + def get_branch(): """ Gets the current branch name in the current git repository - @return: The current branch name + @return: The current branch name, None if it can't be determined """ - return subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode("utf-8").strip() + try: + subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode("utf-8").strip() + except subprocess.CalledProcessError: + return None def get_last_commit(): """ Gets the latest commit in the current git repository - @return: (str) the latest commit in the current git repository + @return: (str) the latest commit in the current git repository, None if it can't be determined """ - return subprocess.check_output("git rev-parse --short=7 HEAD", shell=True).decode("utf-8").strip() + try: + return subprocess.check_output("git rev-parse --short=7 HEAD", shell=True).decode("utf-8").strip() + except subprocess.CalledProcessError: + return None -VERSION = "0.6.0-{0}-{1}".format(get_branch(), get_last_commit()) +def check_if_git_repo(): + """ + Checks if we're in a git repo or not to know if we can get the git branch and commit + @return: True if in a git repo, False otherwise + """ + return subprocess.call(["git", "branch"], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) == 0 + + +branch = None +commit = None + +DEV_VERSION = VERSION + +if check_if_git_repo(): + branch = get_branch() + commit = get_last_commit() + DEV_VERSION += "-{0}".format(branch) + DEV_VERSION += "-{0}".format(commit) + + if __name__ == '__main__': print(VERSION) Index: tests/test_print_version.py =================================================================== diff -u --- tests/test_print_version.py (revision 0) +++ tests/test_print_version.py (revision 01777f61bd58d75904abc7f29033813f0e947736) @@ -0,0 +1,20 @@ +########################################################################### +# +# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# +# THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +# WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +# +# @file test_print_version.py +# +# @author (last) Peter Lucia +# @date (last) 19-Aug-2020 +# @author (original) Peter Lucia +# @date (original) 19-Aug-2020 +# +############################################################################ +import sys +sys.path.append("..") + +import dialin +print(dialin.__version__) \ No newline at end of file