Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3006.x] Update for deprecation of hex in pygit2 1.15.0 and above #67105

Open
wants to merge 5 commits into
base: 3006.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/67017.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update for deprecation of hex in pygit2 1.15.0 and above
15 changes: 9 additions & 6 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ def _val_cb(x, y):
if HAS_PSUTIL:
cur_pid = os.getpid()
process = psutil.Process(cur_pid)
dgm_process_dir = dir(process)
cache_dir = self.opts.get("cachedir", None)
gitfs_active = self.opts.get("gitfs_remotes", None)
if cache_dir and gitfs_active:
Expand Down Expand Up @@ -1780,7 +1779,7 @@ def checkout(self, fetch_on_fail=True):
return None

try:
head_sha = self.peel(local_head).hex
head_sha = str(self.peel(local_head).id)
except AttributeError:
# Shouldn't happen, but just in case a future pygit2 API change
# breaks things, avoid a traceback and log an error.
Expand Down Expand Up @@ -1839,7 +1838,10 @@ def _perform_checkout(checkout_ref, branch=True):
self.repo.create_reference(local_ref, pygit2_id)

try:
target_sha = self.peel(self.repo.lookup_reference(remote_ref)).hex
target_sha = str(
self.peel(self.repo.lookup_reference(remote_ref)).id
)

except KeyError:
log.error(
"pygit2 was unable to get SHA for %s in %s remote '%s'",
Expand Down Expand Up @@ -1920,10 +1922,11 @@ def _perform_checkout(checkout_ref, branch=True):
else:
try:
# If no AttributeError raised, this is an annotated tag
tag_sha = tag_obj.target.hex
tag_sha = str(tag_obj.target.id)

except AttributeError:
try:
tag_sha = tag_obj.hex
tag_sha = str(tag_obj.id)
except AttributeError:
# Shouldn't happen, but could if a future pygit2
# API change breaks things.
Expand Down Expand Up @@ -2277,7 +2280,7 @@ def find_file(self, path, tgt_env):
blob = None
break
if isinstance(blob, pygit2.Blob):
return blob, blob.hex, mode
return blob, str(blob.id), mode
return None, None, None

def get_tree_from_branch(self, ref):
Expand Down
Loading