From ca6d3fc9bc62e7a3c9ffef1fe4baf0dfe0716ee7 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:17:06 -0700 Subject: 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. --- tests/t0202-submodule-links.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'tests/t0202-submodule-links.sh') 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" 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" 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" 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 ' -- cgit