77 lines
3.0 KiB
Plaintext
77 lines
3.0 KiB
Plaintext
$OpenBSD: patch-salt_utils_gitfs_py,v 1.1 2019/02/28 16:34:59 jasper Exp $
|
|
|
|
https://github.com/saltstack/salt/pull/51304/commits/c02757d70b38813e566a47954fc1118a55c8116d
|
|
|
|
Index: salt/utils/gitfs.py
|
|
--- salt/utils/gitfs.py.orig
|
|
+++ salt/utils/gitfs.py
|
|
@@ -1395,6 +1395,19 @@ class Pygit2(GitProvider):
|
|
override_params, cache_root, role
|
|
)
|
|
|
|
+ def peel(self, obj):
|
|
+ '''
|
|
+ Compatibility function for pygit2.Reference objects. Older versions of
|
|
+ pygit2 use .get_object() to return the object to which the reference
|
|
+ points, while newer versions use .peel(). In pygit2 0.27.4,
|
|
+ .get_object() was removed. This function will try .peel() first and
|
|
+ fall back to .get_object().
|
|
+ '''
|
|
+ try:
|
|
+ return obj.peel()
|
|
+ except AttributeError:
|
|
+ return obj.get_object()
|
|
+
|
|
def checkout(self):
|
|
'''
|
|
Checkout the configured branch/tag
|
|
@@ -1413,7 +1426,7 @@ class Pygit2(GitProvider):
|
|
return None
|
|
|
|
try:
|
|
- head_sha = local_head.get_object().hex
|
|
+ head_sha = self.peel(local_head).hex
|
|
except AttributeError:
|
|
# Shouldn't happen, but just in case a future pygit2 API change
|
|
# breaks things, avoid a traceback and log an error.
|
|
@@ -1462,7 +1475,7 @@ class Pygit2(GitProvider):
|
|
try:
|
|
if remote_ref in refs:
|
|
# Get commit id for the remote ref
|
|
- oid = self.repo.lookup_reference(remote_ref).get_object().id
|
|
+ oid = self.peel(self.repo.lookup_reference(remote_ref)).id
|
|
if local_ref not in refs:
|
|
# No local branch for this remote, so create one and point
|
|
# it at the commit id of the remote ref
|
|
@@ -1470,7 +1483,7 @@ class Pygit2(GitProvider):
|
|
|
|
try:
|
|
target_sha = \
|
|
- self.repo.lookup_reference(remote_ref).get_object().hex
|
|
+ self.peel(self.repo.lookup_reference(remote_ref)).hex
|
|
except KeyError:
|
|
log.error(
|
|
'pygit2 was unable to get SHA for %s in %s remote '
|
|
@@ -1848,8 +1861,8 @@ class Pygit2(GitProvider):
|
|
refs/remotes/origin/
|
|
'''
|
|
try:
|
|
- return self.repo.lookup_reference(
|
|
- 'refs/remotes/origin/{0}'.format(ref)).get_object().tree
|
|
+ return self.peel(self.repo.lookup_reference(
|
|
+ 'refs/remotes/origin/{0}'.format(ref))).tree
|
|
except KeyError:
|
|
return None
|
|
|
|
@@ -1858,8 +1871,8 @@ class Pygit2(GitProvider):
|
|
Return a pygit2.Tree object matching a tag ref fetched into refs/tags/
|
|
'''
|
|
try:
|
|
- return self.repo.lookup_reference(
|
|
- 'refs/tags/{0}'.format(ref)).get_object().tree
|
|
+ return self.peel(self.repo.lookup_reference(
|
|
+ 'refs/tags/{0}'.format(ref))).tree
|
|
except KeyError:
|
|
return None
|
|
|