Diff options
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0110-snapshot.sh30
1 file changed, 30 insertions, 0 deletions
diff --git a/tests/t0110-snapshot.sh b/tests/t0110-snapshot.sh
index bec0e3d..e3b8087 100755
--- a/tests/t0110-snapshot.sh
+++ b/tests/t0110-snapshot.sh
@@ -167,6 +167,36 @@ test_expect_success 'an empty snapshot-prefix puts no slash ahead of the members
! grep "^/" members
'
+# A snapshot is named after the last component of the url once its .git
+# suffix is gone, so a url of .git alone leaves the ref as the whole name.
+test_expect_success 'set up repositories whose urls end in .git' '
+ mkrepo repos/dotgit 1 &&
+ git -C repos/dotgit tag v1.0 &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "snapshots=tar" &&
+ echo "repo.url=.git" &&
+ echo "repo.path=$PWD/repos/dotgit/.git" &&
+ echo "repo.url=sub/.git" &&
+ echo "repo.path=$PWD/repos/dotgit/.git"
+ } >dotgitrc
+'
+
+test_expect_success 'a url of .git names a snapshot after the ref alone' '
+ CGIT_CONFIG="$PWD/dotgitrc" QUERY_STRING="url=.git/refs/" cgit >tmp &&
+ grep ">v1.0.tar<" tmp &&
+ CGIT_CONFIG="$PWD/dotgitrc" QUERY_STRING="url=.git/snapshot/v1.0.tar" cgit >tmp &&
+ strip_headers <tmp >dotgit.tar &&
+ tar -tf dotgit.tar >members &&
+ grep "^v1.0/file-1$" members
+'
+
+test_expect_success 'a url ending in /.git names a snapshot after its directory' '
+ CGIT_CONFIG="$PWD/dotgitrc" QUERY_STRING="url=sub/.git/refs/" cgit >tmp &&
+ grep ">sub-1.0.tar<" tmp
+'
+
# A server may run cgit with no PATH at all, and the compressor is then looked
# for on the default path execvp searches.
test_expect_success GZIP 'a compressed snapshot is made without a PATH' '