Commit c5cc46ac authored by Cresson Remi's avatar Cresson Remi
Browse files

FIX: get hash

1 merge request!4ADD: use otbtf 3.2.1 in unit tests
Pipeline #36503 passed with stages
in 9 minutes and 53 seconds
Showing with 9 additions and 6 deletions
+9 -6
...@@ -41,13 +41,16 @@ def get_commit_hash(): ...@@ -41,13 +41,16 @@ def get_commit_hash():
""" Return the git hash of the repository """ """ Return the git hash of the repository """
repo = git.Repo(os.path.dirname(os.path.realpath(__file__)), search_parent_directories=True) repo = git.Repo(os.path.dirname(os.path.realpath(__file__)), search_parent_directories=True)
commit_hash = "nohash"
try: try:
commit_hash = repo.active_branch.name + "_" + repo.head.object.hexsha[0:5] commit_hash = repo.head.object.hexsha[0:5]
except TypeError: except (ValueError, TypeError) as e:
try: print(f"Unable to get commit hash! {e}")
commit_hash = 'DETACHED_' + repo.head.object.hexsha[0:5]
except ValueError: try:
commit_hash = 'NoHash' commit_hash = repo.active_branch.name + "_" + commit_hash
except (ValueError, TypeError) as e:
print(f"Unable to get branch name! {e}")
return commit_hash return commit_hash
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment