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

Automatically exclude alt links and template files

unless yadm.auto-exclude is set to false (#234, #465).

Alt files exclude pattern will be written to $GIT_DIR/info/exclude.yadm-alt and
encrypt files exclude patthern to ...yadm-encrypt. Then these two files will be
merged together and added to $GIT_DIR/info/exclude whenever one of them has
changed.
This commit is contained in:
Erik Flodin
2025-02-27 21:18:07 +01:00
parent 6726730701
commit d4796108f4
4 changed files with 110 additions and 54 deletions

View File

@@ -217,6 +217,29 @@ def test_auto_alt(runner, yadm_cmd, paths, autoalt):
assert str(paths.work.join(source_file)) not in linked
@pytest.mark.usefixtures("ds1_copy")
@pytest.mark.parametrize("autoexclude", [None, "true", "false"])
def test_alt_exclude(runner, yadm_cmd, paths, autoexclude):
"""Test alt exclude"""
# set the value of auto-exclude
if autoexclude:
os.system(" ".join(yadm_cmd("config", "yadm.auto-exclude", autoexclude)))
utils.create_alt_files(paths, "##default")
run = runner(yadm_cmd("alt", "-d"))
assert run.success
run = runner(yadm_cmd("status", "-z", "-uall", "--ignored"))
assert run.success
assert run.err == ""
status = run.out.split("\0")
for link_path in TEST_PATHS:
flags = "??" if autoexclude == "false" else "!!"
assert f"{flags} {link_path}" in status
@pytest.mark.usefixtures("ds1_copy")
def test_stale_link_removal(runner, yadm_cmd, paths):
"""Stale links to alternative files are removed

View File

@@ -9,7 +9,12 @@ import pytest
def test_exclude_encrypted(runner, tmpdir, yadm, encrypt_exists, auto_exclude, exclude):
"""Test exclude_encrypted()"""
header = "# yadm-auto-excludes\n# This section is managed by yadm.\n# Any edits below will be lost.\n"
header = """\
# yadm-auto-excludes
# This section is managed by yadm.
# Any edits below will be lost.
# yadm encrypt
"""
config_function = 'function config() { echo "false";}'
if auto_exclude: