We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b78a14 commit b9391bdCopy full SHA for b9391bd
scmrepo/git/backend/pygit2.py
@@ -251,7 +251,14 @@ def is_dirty(self, untracked_files: bool = False) -> bool:
251
raise NotImplementedError
252
253
def active_branch(self) -> str:
254
- raise NotImplementedError
+ if self.repo.head_is_detached:
255
+ raise SCMError("No active branch (detached HEAD)")
256
+ if self.repo.head_is_unborn:
257
+ # if HEAD points to a nonexistent branch we still return the
258
+ # branch name (without "refs/heads/" prefix) to match gitpython's
259
+ # behavior
260
+ return self.repo.references["HEAD"].target[11:]
261
+ return self.repo.head.shorthand
262
263
def list_branches(self) -> Iterable[str]:
264
0 commit comments