Bug 1908311 - Fix GitRepository.branch with older versions of git. r=sheehan

Differential Revision: https://phabricator.services.mozilla.com/D216786
This commit is contained in:
Mike Hommey 2024-07-17 21:06:48 +00:00
parent d7c6c15874
commit c7188972f0

View File

@ -806,7 +806,11 @@ class GitRepository(Repository):
@property
def branch(self):
return self._run("branch", "--show-current").strip() or None
# This mimics `git branch --show-current` for older versions of git.
branch = self._run("symbolic-ref", "-q", "HEAD").strip()
if not branch.startswith("refs/heads/"):
return None
return branch[len("refs/heads/") :]
@property
def has_git_cinnabar(self):