mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #33727 from terminalmage/issue33725
Fix git_pillar edge case for remote repos without a master branch
This commit is contained in:
commit
b07701f0a0
1 changed files with 8 additions and 5 deletions
|
@ -1045,11 +1045,14 @@ class Pygit2(GitProvider):
|
|||
return None
|
||||
remote_head = 'refs/remotes/origin/' + branch_name
|
||||
if remote_head not in refs:
|
||||
log.error(
|
||||
'Unable to find remote ref \'{0}\' in {1} remote '
|
||||
'\'{2}\''.format(head_ref, self.role, self.id)
|
||||
)
|
||||
return None
|
||||
# No remote ref for HEAD exists. This can happen in
|
||||
# the first-time git_pillar checkout when when the
|
||||
# remote repo does not have a master branch. Since
|
||||
# we need a HEAD reference to keep pygit2 from
|
||||
# throwing an error, and none exists in
|
||||
# refs/remotes/origin, we'll just point HEAD at the
|
||||
# remote_ref.
|
||||
remote_head = remote_ref
|
||||
self.repo.create_reference(
|
||||
head_ref,
|
||||
self.repo.lookup_reference(remote_head).target
|
||||
|
|
Loading…
Add table
Reference in a new issue