Remove reporting of invalid alts
This commit is contained in:
parent
62a86ecd27
commit
13a3cdc8a8
3 changed files with 0 additions and 84 deletions
|
@ -1,34 +0,0 @@
|
||||||
"""Unit tests: report_invalid_alts"""
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
'condition', [
|
|
||||||
'previous-message',
|
|
||||||
'invalid-alts',
|
|
||||||
'no-invalid-alts',
|
|
||||||
])
|
|
||||||
def test_report_invalid_alts(runner, yadm, condition):
|
|
||||||
"""Use report_invalid_alts"""
|
|
||||||
|
|
||||||
previous = ''
|
|
||||||
alts = 'INVALID_ALT=()'
|
|
||||||
if condition == 'previous-message':
|
|
||||||
previous = 'LEGACY_WARNING_ISSUED=1'
|
|
||||||
if condition == 'invalid-alts':
|
|
||||||
alts = 'INVALID_ALT=("file##invalid")'
|
|
||||||
|
|
||||||
script = f"""
|
|
||||||
YADM_TEST=1 source {yadm}
|
|
||||||
{previous}
|
|
||||||
{alts}
|
|
||||||
report_invalid_alts
|
|
||||||
"""
|
|
||||||
run = runner(command=['bash'], inp=script)
|
|
||||||
assert run.success
|
|
||||||
assert run.err == ''
|
|
||||||
if condition == 'invalid-alts':
|
|
||||||
assert 'WARNING' in run.out
|
|
||||||
assert 'file##invalid' in run.out
|
|
||||||
else:
|
|
||||||
assert run.out == ''
|
|
|
@ -260,19 +260,3 @@ def test_template_recording(runner, yadm, cmd_generated):
|
||||||
assert run.success
|
assert run.success
|
||||||
assert run.err == ''
|
assert run.err == ''
|
||||||
assert run.out.rstrip() == expected
|
assert run.out.rstrip() == expected
|
||||||
|
|
||||||
|
|
||||||
def test_invalid(runner, yadm):
|
|
||||||
"""Verify invalid alternates are noted in INVALID_ALT"""
|
|
||||||
|
|
||||||
invalid_file = "file##invalid"
|
|
||||||
|
|
||||||
script = f"""
|
|
||||||
YADM_TEST=1 source {yadm}
|
|
||||||
score_file "{invalid_file}"
|
|
||||||
echo "INVALID:${{INVALID_ALT[@]}}"
|
|
||||||
"""
|
|
||||||
run = runner(command=['bash'], inp=script)
|
|
||||||
assert run.success
|
|
||||||
assert run.err == ''
|
|
||||||
assert run.out.rstrip() == f'INVALID:{invalid_file}'
|
|
||||||
|
|
34
yadm
34
yadm
|
@ -62,7 +62,6 @@ GPG_OPTS=()
|
||||||
OPENSSL_OPTS=()
|
OPENSSL_OPTS=()
|
||||||
|
|
||||||
LEGACY_WARNING_ISSUED=0
|
LEGACY_WARNING_ISSUED=0
|
||||||
INVALID_ALT=()
|
|
||||||
|
|
||||||
# flag causing path translations with cygpath
|
# flag causing path translations with cygpath
|
||||||
USE_CYGPATH=0
|
USE_CYGPATH=0
|
||||||
|
@ -232,7 +231,6 @@ function score_file() {
|
||||||
return 0
|
return 0
|
||||||
# unsupported values
|
# unsupported values
|
||||||
else
|
else
|
||||||
INVALID_ALT+=("$src")
|
|
||||||
score=0
|
score=0
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -545,41 +543,9 @@ function alt() {
|
||||||
|
|
||||||
alt_linking
|
alt_linking
|
||||||
remove_stale_links
|
remove_stale_links
|
||||||
report_invalid_alts
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function report_invalid_alts() {
|
|
||||||
[ "$LEGACY_WARNING_ISSUED" = "1" ] && return
|
|
||||||
[ "${#INVALID_ALT[@]}" = "0" ] && return
|
|
||||||
local path_list
|
|
||||||
for invalid in "${INVALID_ALT[@]}"; do
|
|
||||||
path_list="$path_list * $invalid"$'\n'
|
|
||||||
done
|
|
||||||
cat <<EOF
|
|
||||||
|
|
||||||
**WARNING**
|
|
||||||
Invalid alternates have been detected.
|
|
||||||
|
|
||||||
Beginning with version 2.0.0, yadm uses a new naming convention for alternate
|
|
||||||
files. Read more about this change here:
|
|
||||||
|
|
||||||
https://yadm.io/docs/upgrade_from_1
|
|
||||||
|
|
||||||
Or to learn more about alternates in general, read:
|
|
||||||
|
|
||||||
https://yadm.io/docs/alternates
|
|
||||||
|
|
||||||
To rename the invalid alternates run:
|
|
||||||
|
|
||||||
yadm mv <old name> <new name>
|
|
||||||
|
|
||||||
Invalid alternates detected:
|
|
||||||
${path_list}
|
|
||||||
***********
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
function remove_stale_links() {
|
function remove_stale_links() {
|
||||||
# review alternate candidates for stale links
|
# review alternate candidates for stale links
|
||||||
# if a possible alt IS linked, but it's source is not part of alt_linked,
|
# if a possible alt IS linked, but it's source is not part of alt_linked,
|
||||||
|
|
Loading…
Reference in a new issue