Skip to content

Commit

Permalink
Fixed tests when in detached head mode
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoRoos committed Jan 16, 2025
1 parent 2f61bbe commit ff31903
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/tctools/git_info/git_info_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ def _get_info(self, repo: Repo) -> Dict[str, str]:

empty = "[empty]"

branch = empty
if git_hash:
try:
branch = repo.active_branch.name
except TypeError:
pass

return {
"HASH": git_hash or empty,
"HASH_SHORT": git_hash[:8] if git_hash else empty,
Expand All @@ -112,7 +119,7 @@ def _get_info(self, repo: Repo) -> Dict[str, str]:
else empty
),
"TAG": repo.git.tag() if git_hash else empty,
"BRANCH": repo.active_branch.name if git_hash else empty,
"BRANCH": branch,
"DESCRIPTION": (
repo.git.describe("--tags", "--always") if git_hash else empty
),
Expand Down

0 comments on commit ff31903

Please sign in to comment.