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