Commit 32e949dd authored by Remi Cresson's avatar Remi Cresson
Browse files

ENH: more permissive failsafe for git

1 merge request!7FIX: follow API changes in pyotb
Pipeline #39789 failed with stages
in 14 minutes and 36 seconds
Showing with 6 additions and 9 deletions
+6 -9
......@@ -41,16 +41,13 @@ def get_commit_hash():
""" Return the git hash of the repository """
repo = git.Repo(os.path.dirname(os.path.realpath(__file__)), search_parent_directories=True)
commit_hash = "nohash"
try:
commit_hash = repo.head.object.hexsha[0:5]
except (ValueError, TypeError) as e:
print(f"Unable to get commit hash! {e}")
try:
commit_hash = repo.active_branch.name + "_" + commit_hash
except (ValueError, TypeError) as e:
print(f"Unable to get branch name! {e}")
commit_hash = repo.active_branch.name + "_" + repo.head.object.hexsha[0:5]
except (TypeError, ValueError, BrokenPipeError):
try:
commit_hash = 'DETACHED_' + repo.head.object.hexsha[0:5]
except (ValueError, BrokenPipeError):
commit_hash = 'DETACHED'
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