diff --git a/scmrepo/git/backend/gitpython.py b/scmrepo/git/backend/gitpython.py index b0270a9d..a4ac0d2b 100644 --- a/scmrepo/git/backend/gitpython.py +++ b/scmrepo/git/backend/gitpython.py @@ -293,7 +293,10 @@ def is_dirty(self, untracked_files: bool = False) -> bool: return self.repo.is_dirty(untracked_files=untracked_files) def active_branch(self): - return self.repo.active_branch.name + try: + return self.repo.active_branch.name + except TypeError as exc: + raise SCMError("No active branch") from exc def list_branches(self): return [h.name for h in self.repo.heads]