diff --git a/decloud/core/system.py b/decloud/core/system.py index 0b9f47558187daaea4af12b43c058f87da969973..d43fb85bf77291d7dc3d31adfdf0b4aca714b791 100644 --- a/decloud/core/system.py +++ b/decloud/core/system.py @@ -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