Compare commits
7 commits
3abfd103cf
...
04df6e42e0
Author | SHA1 | Date | |
---|---|---|---|
|
04df6e42e0 | ||
|
6ee9b472d1 | ||
|
ae3a149449 | ||
|
85e8c1ddfc | ||
|
a7939bec7b | ||
|
aba434274e | ||
|
12c51e130b |
4 changed files with 41 additions and 9 deletions
|
@ -175,7 +175,7 @@ def test_alt_template_with_condition(runner, paths, tst_arch):
|
|||
"""Test template with extra condition"""
|
||||
yadm_dir, yadm_data = setup_standard_yadm_dir(paths)
|
||||
|
||||
suffix = f"##default,arch.not{tst_arch}"
|
||||
suffix = f"##template,arch.not{tst_arch}"
|
||||
utils.create_alt_files(paths, suffix)
|
||||
run = runner([paths.pgm, "-Y", yadm_dir, "--yadm-data", yadm_data, "alt"])
|
||||
assert run.success
|
||||
|
|
|
@ -326,3 +326,31 @@ def test_no_repo(
|
|||
def verify_head(paths, branch):
|
||||
"""Assert the local repo has the correct head branch"""
|
||||
assert paths.repo.join("HEAD").read() == f"ref: refs/heads/{branch}\n"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("remote")
|
||||
def test_clone_subdirectory(runner, paths, yadm_cmd, repo_config):
|
||||
"""Test clone from sub-directory of YADM_WORK"""
|
||||
|
||||
# clear out the work path
|
||||
paths.work.remove()
|
||||
paths.work.mkdir()
|
||||
|
||||
# create sub-directory
|
||||
subdir = paths.work.mkdir("subdir")
|
||||
|
||||
# determine remote url
|
||||
remote_url = f"file://{paths.remote}"
|
||||
|
||||
# run the clone command
|
||||
args = ["clone", "-w", paths.work, remote_url]
|
||||
run = runner(command=yadm_cmd(*args), cwd=subdir)
|
||||
|
||||
# clone should succeed, and repo should be configured properly
|
||||
assert successful_clone(run, paths, repo_config)
|
||||
|
||||
# ensure that no changes found as this is a clean dotfiles clone
|
||||
run = runner(command=yadm_cmd("status", "-uno", "--porcelain"), cwd=subdir)
|
||||
assert run.success
|
||||
assert run.out == ""
|
||||
assert run.err == ""
|
||||
|
|
|
@ -289,15 +289,15 @@ def test_template_recording(runner, yadm, cmd_generated):
|
|||
assert run.out.rstrip() == expected
|
||||
|
||||
|
||||
def test_underscores_in_distro_and_family(runner, yadm):
|
||||
"""Test replacing spaces in distro / distro_family with underscores"""
|
||||
def test_underscores_and_upper_case_in_distro_and_family(runner, yadm):
|
||||
"""Test replacing spaces with underscores and lowering case in distro / distro_family"""
|
||||
local_distro = "test distro"
|
||||
local_distro_family = "test family"
|
||||
filenames = {
|
||||
"filename##distro.test distro": 1004,
|
||||
"filename##distro.Test Distro": 1004,
|
||||
"filename##distro.test-distro": 0,
|
||||
"filename##distro.test_distro": 1004,
|
||||
"filename##distro_family.test family": 1008,
|
||||
"filename##distro_family.test FAMILY": 1008,
|
||||
"filename##distro_family.test-family": 0,
|
||||
"filename##distro_family.test_family": 1008,
|
||||
}
|
||||
|
|
12
yadm
12
yadm
|
@ -191,10 +191,14 @@ function score_file() {
|
|||
[ "$value" = "$local_system" ] && delta=2
|
||||
;;
|
||||
d|distro)
|
||||
[ "${value// /_}" = "${local_distro// /_}" ] && delta=4
|
||||
shopt -s nocasematch
|
||||
[[ "${value// /_}" = "${local_distro// /_}" ]] && delta=4
|
||||
shopt -u nocasematch
|
||||
;;
|
||||
f|distro_family)
|
||||
[ "${value// /_}" = "${local_distro_family// /_}" ] && delta=8
|
||||
shopt -s nocasematch
|
||||
[[ "${value// /_}" = "${local_distro_family// /_}" ]] && delta=8
|
||||
shopt -u nocasematch
|
||||
;;
|
||||
c|class)
|
||||
in_list "$value" "${local_classes[@]}" && delta=16
|
||||
|
@ -435,7 +439,7 @@ EOF
|
|||
-v distro="$local_distro" \
|
||||
-v distro_family="$local_distro_family" \
|
||||
-v source="$input" \
|
||||
-v source_dir="$(dirname "$input")" \
|
||||
-v source_dir="$(builtin_dirname "$input")" \
|
||||
"$awk_pgm" \
|
||||
"$input" "${local_classes[@]}" > "$temp_file" || rm -f "$temp_file"
|
||||
|
||||
|
@ -799,7 +803,7 @@ function clone() {
|
|||
rm -rf "$wc"
|
||||
|
||||
# then reset the index as the --no-checkout flag makes the index empty
|
||||
"$GIT_PROGRAM" reset --quiet -- .
|
||||
"$GIT_PROGRAM" reset --quiet -- ":/"
|
||||
|
||||
if [ "$YADM_WORK" = "$HOME" ]; then
|
||||
debug "Determining if repo tracks private directories"
|
||||
|
|
Loading…
Reference in a new issue