1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2026-03-02 03:49:29 +00:00

Process alt files in submodules (#78, #528)

Ignore files are updated in each submodule's info/exclude file. The
top-level file still contains all files (for simplicity).
This commit is contained in:
Erik Flodin
2025-04-06 22:09:19 +02:00
parent bbb58e6625
commit 9b1d7eea00
3 changed files with 121 additions and 53 deletions

View File

@@ -54,6 +54,50 @@ def test_alt_source(runner, paths, tracked, encrypt, exclude, yadm_alt):
assert str(source_file) not in linked
@pytest.mark.usefixtures("ds1_copy")
def test_alt_submodule(runner, paths, yadm_cmd):
"""Test alt handling in submodule"""
yadm_dir, yadm_data = setup_standard_yadm_dir(paths)
# Create alt files in separate alt dir
alt_dir = yadm_dir.join("alt")
utils.create_alt_files(paths, "##default", tracked=False, yadm_alt=True, yadm_dir=yadm_dir)
# Make alt dir be a separate repo
runner(["git", "init", alt_dir], report=False)
runner(["git", "-C", alt_dir, "add", "."], report=False)
run = runner(["git", "-C", alt_dir, "commit", "-m", "Add alt files"])
assert run.success
# And add it as a submodule
run = runner(
yadm_cmd("-Y", yadm_dir, "--yadm-data", yadm_data, "submodule", "add", "https://foobar/repo", alt_dir.basename),
cwd=alt_dir.dirname,
)
assert run.success
# Now when processing alt files
run = runner([paths.pgm, "-Y", yadm_dir, "--yadm-data", yadm_data, "alt"])
assert run.success
assert run.err == ""
linked = utils.parse_alt_output(run.out)
# Then files in submodule are also handled
for link_path in TEST_PATHS:
source_file_content = link_path + "##default"
source_file = alt_dir.join(source_file_content)
link_file = paths.work.join(link_path)
if link_path == utils.ALT_DIR:
source_file = source_file.join(utils.CONTAINED)
link_file = link_file.join(utils.CONTAINED)
assert link_file.islink()
target = py.path.local(os.path.realpath(link_file))
assert target.isfile()
assert link_file.read() == source_file_content
assert str(source_file) in linked
@pytest.mark.usefixtures("ds1_copy")
@pytest.mark.parametrize("yadm_alt", [True, False], ids=["alt", "worktree"])
def test_relative_link(runner, paths, yadm_alt):

View File

@@ -34,6 +34,7 @@ def test_exclude_encrypted(runner, tmpdir, yadm, encrypt_exists, auto_exclude, e
script = f"""
YADM_TEST=1 source {yadm}
{config_function}
GIT_PROGRAM=true
DEBUG=1
YADM_ENCRYPT="{encrypt_file}"
YADM_REPO="{repo_dir}"