Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Add the shared config writers and cgit_rc
The helpers are named by kind. cgitrc_repo and cgitrc_copy write the config file named first, and cgit_url, cgit_query and cgit_rc run cgit, each named after what it is handed first. A repository copies its defaults from the globals read before its repo.url, so cgitrc_repo places every setting itself, and a global can no longer land where it silently stops applying. The t00xx and t01xx files move to them here.
Diffstat (limited to 'tests/t0110-snapshot.sh')
-rwxr-xr-xtests/t0110-snapshot.sh38
1 file changed, 13 insertions, 25 deletions
diff --git a/tests/t0110-snapshot.sh b/tests/t0110-snapshot.sh
index 5478114..faebf5e 100755
--- a/tests/t0110-snapshot.sh
+++ b/tests/t0110-snapshot.sh
@@ -105,17 +105,11 @@ test_expect_success UNZIP 'unzip and verify the content' '
test_expect_success 'set up a repo with a versioned tag' '
mkrepo repos/vtags 2 &&
git -C repos/vtags update-ref refs/tags/v1.0 HEAD &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "snapshots=tar.gz" &&
- echo "repo.url=vtags" &&
- echo "repo.path=$PWD/repos/vtags/.git"
- } >vtagsrc
+ cgitrc_repo vtagsrc vtags snapshots=tar.gz
'
test_expect_success 'a loose v tag still sheds its v in the snapshot name' '
- CGIT_CONFIG="$PWD/vtagsrc" QUERY_STRING="url=vtags/refs/" cgit >tmp &&
+ cgit_rc vtagsrc "url=vtags/refs/" >tmp &&
grep "vtags-1.0.tar.gz" tmp &&
! grep "vtags-v1.0.tar.gz" tmp
'
@@ -125,7 +119,7 @@ test_expect_success 'a loose v tag still sheds its v in the snapshot name' '
test_expect_success 'a real case collision keeps the v on both tags' '
git -C repos/vtags pack-refs --all &&
git -C repos/vtags update-ref refs/tags/V1.0 HEAD~1 &&
- CGIT_CONFIG="$PWD/vtagsrc" QUERY_STRING="url=vtags/refs/" cgit >tmp &&
+ cgit_rc vtagsrc "url=vtags/refs/" >tmp &&
grep "vtags-v1.0.tar.gz" tmp &&
grep "vtags-V1.0.tar.gz" tmp &&
! grep "vtags-1.0.tar.gz" tmp
@@ -136,7 +130,7 @@ test_expect_success 'a real case collision keeps the v on both tags' '
test_expect_success 'a snapshot name with nothing before its suffix is refused' '
git -C repos/vtags branch v HEAD &&
sed "s/^snapshots=tar.gz$/snapshots=tar/" vtagsrc >vtagstarrc &&
- CGIT_CONFIG="$PWD/vtagstarrc" QUERY_STRING="url=vtags/snapshot/.tar" cgit >tmp &&
+ cgit_rc vtagstarrc "url=vtags/snapshot/.tar" >tmp &&
grep "^Status: 404" tmp
'
@@ -145,7 +139,7 @@ test_expect_success 'an empty snapshot-prefix puts no slash ahead of the members
cat vtagstarrc &&
echo "repo.snapshot-prefix="
} >noprefixrc &&
- CGIT_CONFIG="$PWD/noprefixrc" QUERY_STRING="url=vtags/snapshot/vtags.tar&id=master" cgit >tmp &&
+ cgit_rc noprefixrc "url=vtags/snapshot/vtags.tar&id=master" >tmp &&
strip_headers <tmp >noprefix.tar &&
tar -tf noprefix.tar >members &&
grep "^file-1$" members &&
@@ -169,23 +163,23 @@ test_expect_success 'set up repositories whose urls end in .git' '
'
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 &&
+ cgit_rc dotgitrc "url=.git/refs/" >tmp &&
grep ">v1.0.tar<" tmp &&
- CGIT_CONFIG="$PWD/dotgitrc" QUERY_STRING="url=.git/snapshot/v1.0.tar" cgit >tmp &&
+ cgit_rc dotgitrc "url=.git/snapshot/v1.0.tar" >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 &&
+ cgit_rc dotgitrc "url=sub/.git/refs/" >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' '
- sed "s/^cache-size=.*/cache-size=0/" cgitrc >nopathrc &&
+ cgitrc_copy nopathrc &&
cgit_bin=$(command -v cgit) &&
(
unset PATH &&
@@ -200,7 +194,7 @@ test_expect_success GZIP 'a compressed snapshot is made without a PATH' '
# that tag even when a branch is spelled like the tag's stem.
test_expect_success GZIP 'a snapshot name leads to the tag ahead of a branch' '
git -C repos/vtags update-ref refs/heads/1.0 $(git -C repos/vtags commit-tree -m shadow HEAD^{tree}) &&
- CGIT_CONFIG="$PWD/vtagsrc" QUERY_STRING="url=vtags/snapshot/vtags-1.0.tar.gz" cgit >tmp &&
+ cgit_rc vtagsrc "url=vtags/snapshot/vtags-1.0.tar.gz" >tmp &&
strip_headers <tmp >tag.tar.gz &&
test "$(gzip -dc tag.tar.gz | git -C repos/vtags get-tar-commit-id)" = "$(git -C repos/vtags rev-parse refs/tags/v1.0^{commit})"
'
@@ -213,7 +207,7 @@ test_expect_success 'a signature past max-blob-size is refused' '
echo "max-blob-size=1" &&
cat vtagsrc
} >sigrc &&
- CGIT_CONFIG="$PWD/sigrc" QUERY_STRING="url=vtags/snapshot/vtags-1.0.tar.gz.asc" cgit >tmp &&
+ cgit_rc sigrc "url=vtags/snapshot/vtags-1.0.tar.gz.asc" >tmp &&
grep "^Status: 413" tmp
'
@@ -228,14 +222,8 @@ test_expect_success 'a snapshot and its signature are linked as one unit' '
sig=$(echo signature | git hash-object -w --stdin) &&
git notes --ref signatures/tar.gz add -C $sig one
) &&
- {
- echo "virtual-root=/" &&
- echo "cache-size=0" &&
- echo "snapshots=tar.gz" &&
- echo "repo.url=signed" &&
- echo "repo.path=$PWD/repos/signed/.git"
- } >signedrc &&
- CGIT_CONFIG="$PWD/signedrc" QUERY_STRING="url=signed/refs/" cgit >tmp &&
+ cgitrc_repo signedrc signed snapshots=tar.gz &&
+ cgit_rc signedrc "url=signed/refs/" >tmp &&
grep "<span class=.snapshot.><a href=./signed/snapshot/signed-one.tar.gz.>signed-one.tar.gz</a> (<a href=./signed/snapshot/signed-one.tar.gz.asc.>sig</a>)</span>" tmp
'