Skip to content

Commit

Permalink
fix pygit2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcmarrow committed Aug 27, 2023
1 parent b5437ce commit fea95bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
16 changes: 8 additions & 8 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def __init__(
self._cache_basehash, self._cache_basename
)
self._cachedir = salt.utils.path.join(self._cache_hash, self._cache_basename)
self._salt_working_dir = salt.utils.path.join(self._cachedir, ".git", ".salt")
self._salt_working_dir = salt.utils.path.join(cache_root, "work", self._cache_full_basename)
self._linkdir = salt.utils.path.join(
cache_root, "links", self._cache_full_basename
)
Expand All @@ -494,6 +494,9 @@ def __init__(
msg += " Perhaps git is not available."
log.critical(msg, exc_info=True)
failhard(self.role)
else:
self.verify_auth()
self.setup_callbacks()

if not os.path.isdir(self._salt_working_dir):
os.makedirs(self._salt_working_dir)
Expand Down Expand Up @@ -2483,8 +2486,6 @@ def init_remotes(
)
if hasattr(repo_obj, "repo"):
# Sanity check and assign the credential parameter
repo_obj.verify_auth()
repo_obj.setup_callbacks()
if self.opts["__role"] == "minion" and repo_obj.new:
# Perform initial fetch on masterless minion
repo_obj.fetch()
Expand Down Expand Up @@ -2566,7 +2567,7 @@ def _remove_cache_dir(self, cache_dir):

def _iter_remote_hashes(self):
for item in os.listdir(self.cache_root):
if item in ("hash", "refs", "links"):
if item in ("hash", "refs", "links", "work"):
continue
if os.path.isdir(salt.utils.path.join(self.cache_root, item)):
yield item
Expand Down Expand Up @@ -2645,13 +2646,12 @@ def fetch_remotes(self, remotes=None):
if not remotes or (repo.id, name) in remotes or name in remotes:
try:
# Find and place fetch_request file for all the other branches for this repo
for branch in os.listdir(repo.get_cache_hash()):
repo_work_hash = os.path.split(repo.get_salt_working_dir())[0]
for branch in os.listdir(repo_work_hash):
# Don't place fetch request in current branch being updated
if branch == repo.get_cache_basename():
continue
branch_salt_dir = salt.utils.path.join(
repo.get_cache_hash(), branch, ".git", ".salt"
)
branch_salt_dir = salt.utils.path.join(repo_work_hash, branch)
fetch_path = salt.utils.path.join(
branch_salt_dir, "fetch_request"
)
Expand Down
7 changes: 3 additions & 4 deletions tests/pytests/functional/utils/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import salt.utils.files
import salt.utils.path

_ROOT_DIR = (
_DUMMY_FILES = (
"data.txt",
"foo.t2",
"bar.t3",
Expand All @@ -15,7 +15,7 @@


def _make_dummy_files(tmp_path):
for full_path in _ROOT_DIR:
for full_path in _DUMMY_FILES:
full_path = salt.utils.path.join(tmp_path, full_path)
path, _ = os.path.split(full_path)
if not os.path.isdir(path):
Expand All @@ -31,9 +31,8 @@ def _dummy_files_exists(tmp_path):
None if some files exists and others are missing
"""
ret = None
for full_path in _ROOT_DIR:
for full_path in _DUMMY_FILES:
full_path = salt.utils.path.join(tmp_path, full_path)
path, _ = os.path.split(full_path)
is_file = os.path.isfile(full_path)
if ret is None:
ret = is_file
Expand Down
Empty file.

0 comments on commit fea95bb

Please sign in to comment.