diff --git a/recce/git.py b/recce/git.py index fd18d585..22f233bf 100644 --- a/recce/git.py +++ b/recce/git.py @@ -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