~edwargix/git.sr.ht

e22daa33f4c194a9e6997188728fe1b7548a4434 — наб 4 years ago 2b40cda
Make Repository.default_branch() simply read the default branch

Alongside the previous commit this preserves the semantic of
"default_branch() == None" being equivalent to "repository empty",
but that is now managed by the post-update hook
1 files changed, 2 insertions(+), 7 deletions(-)

M gitsrht/git.py
M gitsrht/git.py => gitsrht/git.py +2 -7
@@ 52,13 52,8 @@ class Repository(GitRepository):
        return super().get(ref)

    def default_branch(self):
        branch = self.branches.get("master")
        if not branch:
            if not any(self.branches.local):
                return None
            branch = list(self.branches.local)[0]
            branch = self.branches.get(branch)
        return branch
        head_ref = self.lookup_reference("HEAD")
        return self.branches.get(head_ref.target[len("refs/heads/"):])

    def default_branch_name(self):
        branch = self.default_branch()