Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Work out each gitlink's target once
Test bodies run in the main shell, so the target named in the fixture
reaches every check that greps for it.
| -rwxr-xr-x | tests/t0202-submodule-links.sh | 8 | |
| -rwxr-xr-x | tests/t0301-security.sh | 5 |
2 files changed, 2 insertions, 11 deletions
diff --git a/tests/t0202-submodule-links.sh b/tests/t0202-submodule-links.sh index 6db164f..2cbbba7 100755 --- a/tests/t0202-submodule-links.sh +++ b/tests/t0202-submodule-links.sh @@ -11,9 +11,9 @@ test_description='Check submodule links derived from .gitmodules' test_expect_success 'set up a parent repo with submodules' ' mkrepo repos/subtarget 1 && mkrepo repos/subparent 1 && + sub=$(git -C repos/subparent rev-parse HEAD) && ( cd repos/subparent && - sub=$(git rev-parse HEAD) && git update-index --add --cacheinfo 160000,$sub,local-ssh && git update-index --add --cacheinfo 160000,$sub,sibling && git update-index --add --cacheinfo 160000,$sub,forge-https && @@ -59,17 +59,14 @@ test_expect_success 'generate subparent/tree' ' ' test_expect_success 'an ssh url served here links to the local repo' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=./subtarget/tree/?id=$sub.>local-ssh</a>" tmp ' test_expect_success 'its hash links to the local commit page' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=./subtarget/commit/?id=$sub." tmp ' test_expect_success 'a relative url resolves against this repository' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=./subtarget/tree/?id=$sub.>sibling</a>" tmp ' @@ -78,18 +75,15 @@ test_expect_success 'a web url is linked as it is' ' ' test_expect_success 'a known forge hash links to its commit page' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=.https://github.com/example/project/commit/$sub." tmp ' test_expect_success 'an ssh url to a known forge is rewritten' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=.https://github.com/example/other.>forge-ssh</a>" tmp && grep "href=.https://github.com/example/other/commit/$sub." tmp ' test_expect_success 'a cgit host keeps its .git suffix in the commit link' ' - sub=$(git -C repos/subparent rev-parse HEAD~1) && grep "href=.https://git.kernel.org/pub/scm/git/git.git/commit/?id=$sub." tmp ' diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh index 45d472d..453d521 100755 --- a/tests/t0301-security.sh +++ b/tests/t0301-security.sh @@ -221,9 +221,9 @@ test_expect_success 'name-sorted branches are unaffected' ' # working. test_expect_success 'set up a submodule fixture with a hostile module-link' ' mkrepo repos/modlink 1 && + sub=$(git -C repos/modlink rev-parse HEAD) && ( cd repos/modlink && - sub=$(git rev-parse HEAD) && git update-index --add --cacheinfo 160000,$sub,submod && git commit -m gitlink ) && @@ -255,7 +255,6 @@ test_expect_success 'a well-formed module-link still takes name and sha1' ' echo "repo.url=modlink" && echo "repo.path=$PWD/repos/modlink/.git" } >modlinkokrc && - sub=$(git -C repos/modlink rev-parse HEAD~1) && CGIT_CONFIG="$PWD/modlinkokrc" QUERY_STRING="url=modlink/tree/" cgit >tmp && grep "href=./mod/submod/commit/?id=$sub." tmp ' @@ -268,7 +267,6 @@ test_expect_success 'a per-path module-link takes only the sha1' ' echo "repo.path=$PWD/repos/modlink/.git" && echo "repo.module-link.submod=https://example.com/s/?id=%s" } >modlinkpathrc && - sub=$(git -C repos/modlink rev-parse HEAD~1) && CGIT_CONFIG="$PWD/modlinkpathrc" QUERY_STRING="url=modlink/tree/" cgit >tmp && grep "href=.https://example.com/s/?id=$sub." tmp ' @@ -281,7 +279,6 @@ test_expect_success 'a doubled percent in a module-link renders as one' ' echo "repo.url=modlink" && echo "repo.path=$PWD/repos/modlink/.git" } >modlinkpctrc && - sub=$(git -C repos/modlink rev-parse HEAD~1) && CGIT_CONFIG="$PWD/modlinkpctrc" QUERY_STRING="url=modlink/tree/" cgit >tmp && grep "href=./m/submod/%/$sub." tmp ' |
