Remove reporting of invalid alts

This commit is contained in:
Tim Byrne 2020-11-25 23:07:49 -06:00
parent 62a86ecd27
commit 13a3cdc8a8
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
3 changed files with 0 additions and 84 deletions

View File

@ -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 == ''

View File

@ -260,19 +260,3 @@ def test_template_recording(runner, yadm, cmd_generated):
assert run.success
assert run.err == ''
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
View File

@ -62,7 +62,6 @@ GPG_OPTS=()
OPENSSL_OPTS=()
LEGACY_WARNING_ISSUED=0
INVALID_ALT=()
# flag causing path translations with cygpath
USE_CYGPATH=0
@ -232,7 +231,6 @@ function score_file() {
return 0
# unsupported values
else
INVALID_ALT+=("$src")
score=0
return
fi
@ -545,41 +543,9 @@ function alt() {
alt_linking
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() {
# review alternate candidates for stale links
# if a possible alt IS linked, but it's source is not part of alt_linked,