Skip to content

Commit

Permalink
Return none when HEAD is detached
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Apr 9, 2024
1 parent 53e0255 commit 3160545
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions recce/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
def current_branch():
try:
repo = Repo(search_parent_directories=True)
except Exception:
if not repo.active_branch:
return None
return repo.active_branch.name
except TypeError:
# happened when HEAD is a detached symbolic reference
return None

if not repo.active_branch:
except Exception:
return None

return repo.active_branch.name

0 comments on commit 3160545

Please sign in to comment.