aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tools/test-clone.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-19 20:42:12 +0200
committerDanilo M. <danix@danix.xyz>2026-10-19 20:42:12 +0200
commitf6a2524658e113561a102f86997f9e236f22e9d8 (patch)
tree4215899feca591308070480c46daa319a1c42726 /examples/tools/test-clone.sh
parent2d58a44858417510f31ab31bc6f6c54abdbc5503 (diff)
downloaddesktop-assistant-f6a2524658e113561a102f86997f9e236f22e9d8.tar.gz
desktop-assistant-f6a2524658e113561a102f86997f9e236f22e9d8.zip
clone tool: name the target owner-repo
A generic repo such as evgen2571/wallpapers cloned into wallpapers; the target now takes the owner's name, collapsing when owner and repo match and falling back to the bare name when the URL has none.
Diffstat (limited to 'examples/tools/test-clone.sh')
-rwxr-xr-xexamples/tools/test-clone.sh35
1 files changed, 25 insertions, 10 deletions
diff --git a/examples/tools/test-clone.sh b/examples/tools/test-clone.sh
index d84a157..ff45b6d 100755
--- a/examples/tools/test-clone.sh
+++ b/examples/tools/test-clone.sh
@@ -45,33 +45,48 @@ contains() { case "$2" in *"$3"*) ;; *) echo "FAIL $1: '$2' lacks '$3'"; fail=1
count() { grep -cF -- "$1" "$GIT_LOG" || true; }
mapcount() { grep -cF -- "$1" "$CLONE_MAP" || true; }
-# Known host, clean copy: seeded map, straight clone, no question.
+# Known host, clean copy: seeded map, straight clone, no question. Owner and
+# repo both go in the target folder name.
out=$("$here/clone.sh" https://github.com/a/b.git)
-check "github clone" "$out" "cloned https://github.com/a/b.git into $CLONE_ROOT/GITHUB/b"
+check "github clone" "$out" "cloned https://github.com/a/b.git into $CLONE_ROOT/GITHUB/a-b"
check "seed" "$(cat "$CLONE_MAP")" \
"$(printf '%s\t%s\n' github.com GITHUB gitlab.com GITLAB forge.slackware.nl FORGE)"
-check "clone argv" "$(count "clone -- https://github.com/a/b.git $CLONE_ROOT/GITHUB/b")" "1"
+check "clone argv" "$(count "clone -- https://github.com/a/b.git $CLONE_ROOT/GITHUB/a-b")" "1"
# Trailing slash and .git are not part of the repo name.
out=$("$here/clone.sh" https://gitlab.com/a/c.git/)
-check "gitlab repo" "$out" "cloned https://gitlab.com/a/c.git into $CLONE_ROOT/GITLAB/c"
+check "gitlab repo" "$out" "cloned https://gitlab.com/a/c.git into $CLONE_ROOT/GITLAB/a-c"
+
+# A self-named repo is not doubled (firefly-iii/firefly-iii -> firefly-iii).
+out=$("$here/clone.sh" https://github.com/firefly-iii/firefly-iii.git)
+check "self-named" "$out" \
+ "cloned https://github.com/firefly-iii/firefly-iii.git into $CLONE_ROOT/GITHUB/firefly-iii"
+
+# No owner in the URL: the plain repo name.
+out=$("$here/clone.sh" git@github.com:solo.git)
+check "no owner" "$out" "cloned git@github.com:solo.git into $CLONE_ROOT/GITHUB/solo"
+
+# A nested group keeps only its last segment as the owner.
+out=$("$here/clone.sh" https://gitlab.com/group/sub/thing.git)
+check "subgroup" "$out" \
+ "cloned https://gitlab.com/group/sub/thing.git into $CLONE_ROOT/GITLAB/sub-thing"
# Unknown host: ask, do nothing, name the folder to offer.
out=$("$here/clone.sh" https://codeberg.org/a/d)
contains "unknown asks" "$out" "no folder for host codeberg.org"
contains "unknown label" "$out" "to=CODEBERG"
-check "unknown no clone" "$(count "$CLONE_ROOT/CODEBERG/d")" "0"
+check "unknown no clone" "$(count "$CLONE_ROOT/CODEBERG/a-d")" "0"
# Approved folder: clone there and remember it.
out=$("$here/clone.sh" https://codeberg.org/a/d CODEBERG)
-check "approved clone" "$out" "cloned https://codeberg.org/a/d into $CLONE_ROOT/CODEBERG/d"
+check "approved clone" "$out" "cloned https://codeberg.org/a/d into $CLONE_ROOT/CODEBERG/a-d"
check "remembered" "$(mapcount 'codeberg.org')" "1"
check "remembered pair" "$(grep -F 'codeberg.org' "$CLONE_MAP")" \
"$(printf 'codeberg.org\tCODEBERG')"
# Next clone of that host asks nothing.
out=$("$here/clone.sh" https://codeberg.org/a/e)
-check "remembered clone" "$out" "cloned https://codeberg.org/a/e into $CLONE_ROOT/CODEBERG/e"
+check "remembered clone" "$out" "cloned https://codeberg.org/a/e into $CLONE_ROOT/CODEBERG/a-e"
# Re-approving the same folder does not duplicate the map line.
"$here/clone.sh" https://codeberg.org/a/f CODEBERG >/dev/null
@@ -79,11 +94,11 @@ check "no duplicate map line" "$(mapcount 'codeberg.org')" "1"
# Already cloned: ask, do not clone again; update pulls.
out=$("$here/clone.sh" https://github.com/a/b.git)
-contains "already asks" "$out" "already cloned at $CLONE_ROOT/GITHUB/b"
+contains "already asks" "$out" "already cloned at $CLONE_ROOT/GITHUB/a-b"
check "already no reclone" "$(count "clone -- https://github.com/a/b.git")" "1"
out=$("$here/clone.sh" https://github.com/a/b.git "" 1)
-contains "update says" "$out" "updated $CLONE_ROOT/GITHUB/b"
-check "update argv" "$(count "-C $CLONE_ROOT/GITHUB/b pull --ff-only")" "1"
+contains "update says" "$out" "updated $CLONE_ROOT/GITHUB/a-b"
+check "update argv" "$(count "-C $CLONE_ROOT/GITHUB/a-b pull --ff-only")" "1"
# Bad input is refused before anything is created.
"$here/clone.sh" "" >/dev/null 2>&1; check "empty url" "$?" "1"