From 86e5a723f295be3949e33f9fd29a58c61e5ed76e Mon Sep 17 00:00:00 2001 From: Michael Watters Date: Nov 16 2018 21:35:28 +0000 Subject: Fixes #4017 The head name was previously hard coded to master. This causes pull requests on projects which do not have a master branch to fail. --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 83d5cb6..58b0c95 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -945,9 +945,12 @@ class TemporaryClone(object): self.repo = pygit2.Repository(self.repopath) # Make sure that all remote refs are mapped to local ones. + headname = None + if not self.repo.is_empty and not self.repo.head_is_unborn: + headname = self.repo.head.shorthand for branchname in self.repo.branches.remote: localname = branchname.replace("origin/", "") - if localname in ("master", "HEAD"): + if localname in (headname, "HEAD"): # This gets checked out by default continue branch = self.repo.branches.remote.get(branchname)