~edwargix/git.sr.ht

4774e65d0ff3f12dd596867936afff49c95988f9 — Drew DeVault 5 years ago 0d1762f
Fix IndexError on repos with no branches
2 files changed, 6 insertions(+), 1 deletions(-)

M gitsrht/blueprints/repo.py
M gitsrht/git.py
M gitsrht/blueprints/repo.py => gitsrht/blueprints/repo.py +4 -1
@@ 147,7 147,10 @@ def go_get(owner, repo, path):
    ])

def lookup_ref(git_repo, ref, path):
    ref = ref or git_repo.default_branch().name[len("refs/heads/"):]
    branch = git_repo.default_branch()
    if not branch:
        abort(404)
    ref = ref or branch.name[len("refs/heads/"):]
    if not path:
        path = []
    else:

M gitsrht/git.py => gitsrht/git.py +2 -0
@@ 55,6 55,8 @@ class Repository(GitRepository):
    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