Skip to content

Commit 7eabaee

Browse files
committed
Release 3.5.0
* Silence warnings when collecting alt files (#521) * Adjust handling of encrypt patterns to match 3.3.0 and older * Make encrypt exclude patterns only match encrypted files * Automatically exclude alt and template files (#234) * Support negative alt conditions (#365) * Handle filenames with space in bash completion (#341) * Add new yadm.filename template variable (#520)
2 parents 5648f8b + 4f4c5e2 commit 7eabaee

16 files changed

Lines changed: 440 additions & 210 deletions

CHANGES

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
3.5.0
2+
* Silence warnings when collecting alt files (#521)
3+
* Adjust handling of encrypt patterns to match 3.3.0 and older
4+
* Make encrypt exclude patterns only match encrypted files
5+
* Automatically exclude alt and template files (#234)
6+
* Support negative alt conditions (#365)
7+
* Handle filenames with space in bash completion (#341)
8+
* Add new yadm.filename template variable (#520)
9+
110
3.4.0
211
* Improve and harden alt file regeneration (#466)
312
* Fix "yadm config" in fish completion (#491)

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Jonathan Daigle
99
Luis López
1010
Tin Lai
1111
Espen Henriksen
12+
AaronYoung5
1213
Cameron Eagans
1314
Klas Mellbourn
1415
James Clark

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ testhost: require-docker .testyadm
123123
--hostname testhost \
124124
--rm -it \
125125
-v "$(CURDIR)/.testyadm:/bin/yadm:ro" \
126+
-v "$(CURDIR)/completion/bash/yadm:/usr/share/bash-completion/completions/yadm:ro" \
126127
$(IMAGE) \
127128
bash -l
128129

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ The star count helps others discover yadm.
7878
[master-badge]: https://img.shields.io/github/actions/workflow/status/yadm-dev/yadm/test.yml?branch=master
7979
[master-commits]: https://github.com/yadm-dev/yadm/commits/master
8080
[master-date]: https://img.shields.io/github/last-commit/yadm-dev/yadm/master.svg?label=master
81-
[obs-badge]: https://img.shields.io/badge/OBS-v3.4.0-blue
81+
[obs-badge]: https://img.shields.io/badge/OBS-v3.5.0-blue
8282
[obs-link]: https://software.opensuse.org/download.html?project=home%3ATheLocehiliosan%3Ayadm&package=yadm
8383
[releases-badge]: https://img.shields.io/github/tag/yadm-dev/yadm.svg?label=latest+release
8484
[releases-link]: https://github.com/yadm-dev/yadm/releases

completion/bash/yadm

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,85 @@
11
# test if git completion is missing, but loader exists, attempt to load
2-
if ! declare -F _git > /dev/null && ! declare -F __git_wrap__git_main > /dev/null; then
3-
if declare -F _completion_loader > /dev/null; then
2+
if ! declare -F _git >/dev/null && ! declare -F __git_wrap__git_main >/dev/null; then
3+
if declare -F _completion_loader >/dev/null; then
44
_completion_loader git
55
fi
66
fi
77

88
# only operate if git completion is present
9-
if declare -F _git > /dev/null || declare -F __git_wrap__git_main > /dev/null; then
9+
if declare -F _git >/dev/null || declare -F __git_wrap__git_main >/dev/null; then
1010

1111
_yadm() {
1212

1313
local current=${COMP_WORDS[COMP_CWORD]}
1414
local penultimate
15-
if [ "$((COMP_CWORD-1))" -ge "0" ]; then
16-
penultimate=${COMP_WORDS[COMP_CWORD-1]}
15+
if ((COMP_CWORD >= 1)); then
16+
penultimate=${COMP_WORDS[COMP_CWORD - 1]}
1717
fi
1818
local antepenultimate
19-
if [ "$((COMP_CWORD-2))" -ge "0" ]; then
20-
antepenultimate=${COMP_WORDS[COMP_CWORD-2]}
19+
if ((COMP_CWORD >= 2)); then
20+
antepenultimate=${COMP_WORDS[COMP_CWORD - 2]}
2121
fi
2222

2323
local -x GIT_DIR
24-
# shellcheck disable=SC2034
2524
GIT_DIR="$(yadm introspect repo 2>/dev/null)"
2625

2726
case "$penultimate" in
2827
bootstrap)
2928
COMPREPLY=()
3029
return 0
31-
;;
30+
;;
3231
config)
33-
COMPREPLY=( $(compgen -W "$(yadm introspect configs 2>/dev/null)") )
32+
COMPREPLY=($(compgen -W "$(yadm introspect configs 2>/dev/null)"))
3433
return 0
35-
;;
34+
;;
3635
decrypt)
37-
COMPREPLY=( $(compgen -W "-l" -- "$current") )
36+
COMPREPLY=($(compgen -W "-l" -- "$current"))
3837
return 0
39-
;;
38+
;;
4039
init)
41-
COMPREPLY=( $(compgen -W "-f -w" -- "$current") )
40+
COMPREPLY=($(compgen -W "-f -w" -- "$current"))
4241
return 0
43-
;;
42+
;;
4443
introspect)
45-
COMPREPLY=( $(compgen -W "commands configs repo switches" -- "$current") )
44+
COMPREPLY=($(compgen -W "commands configs repo switches" -- "$current"))
4645
return 0
47-
;;
46+
;;
4847
help)
4948
COMPREPLY=() # no specific help yet
5049
return 0
51-
;;
50+
;;
5251
list)
53-
COMPREPLY=( $(compgen -W "-a" -- "$current") )
52+
COMPREPLY=($(compgen -W "-a" -- "$current"))
5453
return 0
55-
;;
54+
;;
5655
esac
5756

5857
case "$antepenultimate" in
5958
clone)
60-
COMPREPLY=( $(compgen -W "-f -w -b --bootstrap --no-bootstrap" -- "$current") )
59+
COMPREPLY=($(compgen -W "-f -w -b --bootstrap --no-bootstrap" -- "$current"))
6160
return 0
62-
;;
61+
;;
6362
esac
6463

65-
local yadm_switches=( $(yadm introspect switches 2>/dev/null) )
64+
local yadm_switches=($(yadm introspect switches 2>/dev/null))
6665

6766
# this condition is so files are completed properly for --yadm-xxx options
6867
if [[ " ${yadm_switches[*]} " != *" $penultimate "* ]]; then
6968
# TODO: somehow solve the problem with [--yadm-xxx option] being
7069
# incompatible with what git expects, namely [--arg=option]
71-
if declare -F _git > /dev/null; then
70+
if declare -F _git >/dev/null; then
7271
_git
7372
else
7473
__git_wrap__git_main
7574
fi
7675
fi
7776
if [[ "$current" =~ ^- ]]; then
78-
local matching
79-
matching=$(compgen -W "${yadm_switches[*]}" -- "$current")
80-
__gitcompappend "$matching"
77+
__gitcompappend "${yadm_switches[*]}" "" "$current" " "
8178
fi
8279

8380
# Find the index of where the sub-command argument should go.
8481
local command_idx
85-
for (( command_idx=1 ; command_idx < ${#COMP_WORDS[@]} ; command_idx++ )); do
82+
for ((command_idx = 1; command_idx < ${#COMP_WORDS[@]}; command_idx++)); do
8683
local command_idx_arg="${COMP_WORDS[$command_idx]}"
8784
if [[ " ${yadm_switches[*]} " = *" $command_idx_arg "* ]]; then
8885
let command_idx++
@@ -93,19 +90,11 @@ if declare -F _git > /dev/null || declare -F __git_wrap__git_main > /dev/null; t
9390
fi
9491
done
9592
if [[ "$COMP_CWORD" = "$command_idx" ]]; then
96-
local matching
97-
matching=$(compgen -W "$(yadm introspect commands 2>/dev/null)" -- "$current")
98-
__gitcompappend "$matching"
93+
__gitcompappend "$(yadm introspect commands 2>/dev/null)" "" "$current" " "
9994
fi
100-
101-
# remove duplicates found in COMPREPLY (a native bash way could be better)
102-
if [ -n "${COMPREPLY[*]}" ]; then
103-
COMPREPLY=($(echo "${COMPREPLY[@]}" | sort -u))
104-
fi
105-
10695
}
10796

108-
complete -o bashdefault -o default -F _yadm yadm 2>/dev/null \
109-
|| complete -o default -F _yadm yadm
97+
complete -o bashdefault -o default -o nospace -F _yadm yadm 2>/dev/null ||
98+
complete -o default -o nospace -F _yadm yadm
11099

111100
fi

test/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,14 @@ def gnupg(tmpdir_factory, runner):
609609
env["GNUPGHOME"] = home
610610

611611
# this pre-populates std files in the GNUPGHOME
612-
runner(["gpg", "-k"], env=env)
612+
runner(["gpg", "-k"], env=env, report=False)
613613

614614
def register_gpg_password(password):
615615
"""Publish a new GPG mock password and flush cached passwords"""
616616
home.join("mock-password").write(password)
617-
runner(["gpgconf", "--reload", "gpg-agent"], env=env)
617+
runner(["gpgconf", "--reload", "gpg-agent"], env=env, report=False)
618618

619619
yield data(home, register_gpg_password)
620620

621-
runner(["gpgconf", "--kill", "gpg-agent"], env=env)
622-
runner(["gpgconf", "--remove-socketdir", "gpg-agent"], env=env)
621+
runner(["gpgconf", "--kill", "gpg-agent"], env=env, report=False)
622+
runner(["gpgconf", "--remove-socketdir", "gpg-agent"], env=env, report=False)

test/test_alt.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,29 @@ def test_auto_alt(runner, yadm_cmd, paths, autoalt):
217217
assert str(paths.work.join(source_file)) not in linked
218218

219219

220+
@pytest.mark.usefixtures("ds1_copy")
221+
@pytest.mark.parametrize("autoexclude", [None, "true", "false"])
222+
def test_alt_exclude(runner, yadm_cmd, paths, autoexclude):
223+
"""Test alt exclude"""
224+
225+
# set the value of auto-exclude
226+
if autoexclude:
227+
os.system(" ".join(yadm_cmd("config", "yadm.auto-exclude", autoexclude)))
228+
229+
utils.create_alt_files(paths, "##default")
230+
run = runner(yadm_cmd("alt", "-d"))
231+
assert run.success
232+
233+
run = runner(yadm_cmd("status", "-z", "-uall", "--ignored"))
234+
assert run.success
235+
assert run.err == ""
236+
status = run.out.split("\0")
237+
238+
for link_path in TEST_PATHS:
239+
flags = "??" if autoexclude == "false" else "!!"
240+
assert f"{flags} {link_path}" in status
241+
242+
220243
@pytest.mark.usefixtures("ds1_copy")
221244
def test_stale_link_removal(runner, yadm_cmd, paths):
222245
"""Stale links to alternative files are removed

test/test_encryption.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def encrypt_targets(yadm_cmd, paths):
9292
paths.work.join("globs dir/globs file2").write("globs file2")
9393
expected.append("globs dir/globs file2")
9494
paths.encrypt.write("globs*\n", mode="a")
95+
paths.encrypt.write("globs d*/globs*\n", mode="a")
9596

9697
# blank lines
9798
paths.encrypt.write("\n \n\t\n", mode="a")
@@ -404,8 +405,8 @@ def test_encrypt_added_to_exclude(runner, yadm_cmd, paths, gnupg):
404405

405406
run = runner(yadm_cmd("encrypt"), env=env)
406407

407-
assert "test-encrypt-data" in paths.repo.join("info/exclude").read()
408-
assert "original-data" in paths.repo.join("info/exclude").read()
408+
assert "test-encrypt-data" in exclude_file.read()
409+
assert "original-data" in exclude_file.read()
409410
assert run.success
410411
assert run.err == ""
411412

test/test_unit_exclude_encrypted.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
def test_exclude_encrypted(runner, tmpdir, yadm, encrypt_exists, auto_exclude, exclude):
1010
"""Test exclude_encrypted()"""
1111

12-
header = "# yadm-auto-excludes\n# This section is managed by yadm.\n# Any edits below will be lost.\n"
12+
header = """\
13+
# yadm-auto-excludes
14+
# This section is managed by yadm.
15+
# Any edits below will be lost.
16+
# yadm encrypt
17+
"""
1318

1419
config_function = 'function config() { echo "false";}'
1520
if auto_exclude:
@@ -24,7 +29,7 @@ def test_exclude_encrypted(runner, tmpdir, yadm, encrypt_exists, auto_exclude, e
2429
if exclude == "outdated":
2530
exclude_file.write(f"original-exclude\n{header}outdated\n", ensure=True)
2631
elif exclude == "up-to-date":
27-
exclude_file.write(f"original-exclude\n{header}test-encrypt-data\n", ensure=True)
32+
exclude_file.write(f"original-exclude\n{header}/test-encrypt-data\n", ensure=True)
2833

2934
script = f"""
3035
YADM_TEST=1 source {yadm}
@@ -42,9 +47,9 @@ def test_exclude_encrypted(runner, tmpdir, yadm, encrypt_exists, auto_exclude, e
4247
if encrypt_exists:
4348
assert exclude_file.exists()
4449
if exclude == "missing":
45-
assert exclude_file.read() == f"{header}test-encrypt-data\n"
50+
assert exclude_file.read() == f"{header}/test-encrypt-data\n"
4651
else:
47-
assert exclude_file.read() == ("original-exclude\n" f"{header}test-encrypt-data\n")
52+
assert exclude_file.read() == ("original-exclude\n" f"{header}/test-encrypt-data\n")
4853
if exclude != "up-to-date":
4954
assert f"Updating {exclude_file}" in run.out
5055
else:

test/test_unit_parse_encrypt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,11 @@ def create_test_encrypt_data(paths):
100100
edata += "*card1\n" # matches same file as the one above
101101
paths.work.join("wildcard1").write("", ensure=True)
102102
paths.work.join("wildcard2").write("", ensure=True)
103+
paths.work.join("subdir/wildcard1").write("", ensure=True)
103104
expected.add("wildcard1")
104105
expected.add("wildcard2")
105106

106-
edata += "dirwild*\n"
107+
edata += "dirwild*/file*\n"
107108
paths.work.join("dirwildcard/file1").write("", ensure=True)
108109
paths.work.join("dirwildcard/file2").write("", ensure=True)
109110
expected.add("dirwildcard/file1")
@@ -125,6 +126,9 @@ def create_test_encrypt_data(paths):
125126
expected.add("ex ex/file4")
126127
expected.add("ex ex/file6.text")
127128

129+
paths.work.join("dirwildcard/file7.ex").write("", ensure=True)
130+
expected.add("dirwildcard/file7.ex")
131+
128132
# double star
129133
edata += "doublestar/**/file*\n"
130134
edata += "!**/file3\n"

0 commit comments

Comments
 (0)