Make the underscore directory standard

This commit is contained in:
Shane Lee 2024-04-09 14:38:35 -06:00 committed by Pedro Algarvio
parent e5d1e4db9d
commit 0c05af434a
6 changed files with 13 additions and 7 deletions

View file

@ -174,7 +174,11 @@ def update_git_repos(opts=None, clean=False, masterless=False):
rev, remote_url = remote_info.strip().split()
except ValueError:
remote_url = remote_info
gittarget = os.path.join(base_dir, targetname).replace(".git", "")
targetname = targetname.replace(".git", "")
# GitFS using pygit2 and gitpython place the repo in a
# subdirectory named `_`. We need to stay consistent when using
# the legacy method as well
gittarget = os.path.join(base_dir, targetname, "_")
if masterless:
result = __salt__["state.single"](
"git.latest",

View file

@ -472,7 +472,7 @@ class GitProvider:
"/", "_"
) # replace "/" with "_" to not cause trouble with file system
self._cache_hash = salt.utils.path.join(cache_root, self._cache_basehash)
self._cache_basename = ""
self._cache_basename = "_"
if self.id.startswith("__env__"):
try:
self._cache_basename = self.get_checkout_target()

View file

@ -41,6 +41,7 @@ def test_update_git_repos(winrepo_remotes):
assert res[remote]
# Make sure there are package definitions in the root
assert res[remote].endswith("_")
pkg_def = os.path.join(res[remote], "7zip.sls")
assert os.path.exists(pkg_def)
@ -63,9 +64,9 @@ def test_legacy_update_git_repos(winrepo_remotes, minion_opts):
# update only returns True or False, not a path
if "-ng" in remote:
path = minion_opts["winrepo_dir_ng"]
pkg_def = os.path.join(path, "salt-winrepo-ng", "7zip.sls")
pkg_def = os.path.join(path, "salt-winrepo-ng", "_", "7zip.sls")
else:
path = minion_opts["winrepo_dir"]
pkg_def = os.path.join(path, "salt-winrepo", "7zip.sls")
pkg_def = os.path.join(path, "salt-winrepo", "_", "7zip.sls")
assert os.path.exists(pkg_def)

View file

@ -7,6 +7,7 @@ from salt.utils.gitfs import GitPillar, GitPython, Pygit2
from salt.utils.immutabletypes import ImmutableDict, ImmutableList
pytestmark = [
pytest.mark.windows_whitelisted,
pytest.mark.slow_test,
]

View file

@ -248,4 +248,4 @@ def test_checkout_pygit2(_prepare_provider):
reason="Skip Pygit2 on windows, due to pygit2 access error on windows"
)
def test_get_cachedir_basename_pygit2(_prepare_provider):
assert "" == _prepare_provider.get_cache_basename()
assert "_" == _prepare_provider.get_cache_basename()

View file

@ -117,11 +117,11 @@ class TestGitBase(TestCase, AdaptedConfigurationTestCaseMixin):
def test_get_cachedir_basename(self):
self.assertEqual(
self.main_class.remotes[0].get_cache_basename(),
"",
"_",
)
self.assertEqual(
self.main_class.remotes[1].get_cache_basename(),
"",
"_",
)
def test_git_provider_mp_lock(self):