Compare commits
13 commits
37008fdb44
...
2e6f7309f9
Author | SHA1 | Date | |
---|---|---|---|
2e6f7309f9 | |||
|
6ee9b472d1 | ||
|
ae3a149449 | ||
|
85e8c1ddfc | ||
|
a7939bec7b | ||
|
aba434274e | ||
|
12c51e130b | ||
9f852c1ad4 | |||
8bfc09c0d8 | |||
a72c566da8 | |||
630b677269 | |||
6d305b2b80 | |||
c6b63cf94b |
2 changed files with 36 additions and 3 deletions
|
@ -326,3 +326,31 @@ def test_no_repo(
|
||||||
def verify_head(paths, branch):
|
def verify_head(paths, branch):
|
||||||
"""Assert the local repo has the correct head branch"""
|
"""Assert the local repo has the correct head branch"""
|
||||||
assert paths.repo.join("HEAD").read() == f"ref: refs/heads/{branch}\n"
|
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 == ""
|
||||||
|
|
11
yadm
11
yadm
|
@ -204,6 +204,7 @@ function score_file() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
elif [[ "$label" =~ ^(d|distro)$ ]]; then
|
elif [[ "$label" =~ ^(d|distro)$ ]]; then
|
||||||
|
value=$("${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$value")
|
||||||
if [ "${value/\ /_}" = "${local_distro/\ /_}" ]; then
|
if [ "${value/\ /_}" = "${local_distro/\ /_}" ]; then
|
||||||
score=$((score + 4))
|
score=$((score + 4))
|
||||||
else
|
else
|
||||||
|
@ -211,6 +212,7 @@ function score_file() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
elif [[ "$label" =~ ^(f|distro_family)$ ]]; then
|
elif [[ "$label" =~ ^(f|distro_family)$ ]]; then
|
||||||
|
value=$("${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$value")
|
||||||
if [ "${value/\ /_}" = "${local_distro_family/\ /_}" ]; then
|
if [ "${value/\ /_}" = "${local_distro_family/\ /_}" ]; then
|
||||||
score=$((score + 8))
|
score=$((score + 8))
|
||||||
else
|
else
|
||||||
|
@ -853,7 +855,7 @@ function clone() {
|
||||||
rm -rf "$wc"
|
rm -rf "$wc"
|
||||||
|
|
||||||
# then reset the index as the --no-checkout flag makes the index empty
|
# 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
|
if [ "$YADM_WORK" = "$HOME" ]; then
|
||||||
debug "Determining if repo tracks private directories"
|
debug "Determining if repo tracks private directories"
|
||||||
|
@ -1548,7 +1550,7 @@ function query_distro() {
|
||||||
fi
|
fi
|
||||||
done < "$OS_RELEASE"
|
done < "$OS_RELEASE"
|
||||||
fi
|
fi
|
||||||
echo "$distro"
|
"${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$distro"
|
||||||
}
|
}
|
||||||
|
|
||||||
function query_distro_family() {
|
function query_distro_family() {
|
||||||
|
@ -1559,10 +1561,13 @@ function query_distro_family() {
|
||||||
family="${line#ID_LIKE=}"
|
family="${line#ID_LIKE=}"
|
||||||
family="${family//\"}"
|
family="${family//\"}"
|
||||||
break
|
break
|
||||||
|
elif [[ -z "$family" && "$line" = ID=* ]]; then
|
||||||
|
family="${line#ID=}"
|
||||||
|
family="${family//\"}"
|
||||||
fi
|
fi
|
||||||
done < "$OS_RELEASE"
|
done < "$OS_RELEASE"
|
||||||
fi
|
fi
|
||||||
echo "$family"
|
"${AWK_PROGRAM[0]}" '{print tolower($0)}' <<<"$distro"
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_global_args() {
|
function process_global_args() {
|
||||||
|
|
Loading…
Reference in a new issue