fix(pages): remove got worktree refs after publishing

Every got checkout creates refs/got/worktree/base-<uuid> in the bare repo. Delete it in the publisher trap so repeated pushes do not accumulate refs and block object cleanup, and assert the ref count stays stable in the hook test.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
This commit is contained in:
lotherk committed 2026-11-22 12:32:06 +00:00
1 parent a5ac6bf52f
commit 17156e1d97
2 files changed
+16

No files matched your search

+6
View File
@@ -58,7 +58,12 @@ parent=$(basename "$(dirname "$repo")")
tmp=""
lock=""
uuid=""
cleanup() {
if [ -n "$uuid" ] && [ -n "${repo:-}" ]; then
got ref -d -r "$repo" \
"refs/got/worktree/base-$uuid" >/dev/null 2>&1 || true
fi
[ -n "$tmp" ] && rm -rf "$tmp"
[ -n "$lock" ] && rmdir "$lock" 2>/dev/null || true
}
@@ -78,6 +83,7 @@ wt="$tmp/wt"
got checkout -q -b "$branch" "$repo" "$wt" ||
die "got checkout of $branch failed"
uuid=$(cat "$wt/.got/uuid" 2>/dev/null || true)
actual=$(cd "$wt" && got log -l 1 | awk '/^commit /{print $2; exit}')
if [ "$actual" != "$rev" ]; then
(cd "$wt" && got update -q -c "$rev") ||
+10
View File
@@ -149,6 +149,8 @@ git clone -q --bare . "$tmp/repos/owner/site.git"
bb_rev=$(git rev-parse pages)
mkdir -p "$tmp/pages"
printf 'owner/site\n' > "$tmp/allow"
refs_before=$(got ref -l -r "$tmp/repos/owner/site.git" |
grep -c 'refs/got/worktree' || true)
GOTEA_PAGES_ROOT="$tmp/pages" GOTEA_BB="$bb" \
"$cgi/pages/publish.sh" "$tmp/repos/owner/site.git" owner/site \
@@ -157,6 +159,10 @@ GOTEA_PAGES_ROOT="$tmp/pages" GOTEA_BB="$bb" \
fail "publish: no index.html"
expect_contains "$(cat "$tmp/pages/owner/site/index.html")" \
'<!DOCTYPE HTML PUBLIC' "publish: bb output"
refs_after=$(got ref -l -r "$tmp/repos/owner/site.git" |
grep -c 'refs/got/worktree' || true)
[ "$refs_before" = "$refs_after" ] ||
fail "publish: worktree ref leaked ($refs_before -> $refs_after)"
echo "PASS publish"
pages_run() {
@@ -212,6 +218,10 @@ hookout=$(printf '%040d %s refs/heads/pages\n' 0 "$bb_rev" |
env -i PATH=/usr/bin:/bin GIT_DIR="$tmp/repos/owner/site.git" \
"$tmp/repos/owner/site.git/hooks/post-receive.d/gotea-pages" 2>&1)
expect_contains "$hookout" "published owner/site" "hook: publish output"
refs_hook=$(got ref -l -r "$tmp/repos/owner/site.git" |
grep -c 'refs/got/worktree' || true)
[ "$refs_before" = "$refs_hook" ] ||
fail "hook: worktree ref leaked ($refs_before -> $refs_hook)"
echo "PASS post-receive hook"
echo "all gotea-cgi tests passed"