clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

Extract site trees with store_tree, as releases do

cat committed 278dd7e
deploy_site and store_tree both extracted a commit's tree into
.forge/store/<tree>/, each with its own copy of the archive, rename and
touch. deploy_site now calls store_tree, so a site and a release share
one way into the store: extracted once, into a temporary directory that
a concurrent extraction of the same tree can't trip over, and touched
when reused, so a gc running meanwhile spares it.

site-preview checks the link points at the stored tree and that a
deploy reusing an old tree makes it count as new.
commit
278dd7e23ea3bca6062e33b208671a8d6f324b52
parent
d3d8e6e71b950198b28854ef7629a0196cfc86ff
author
cat <admin@dev.site>
kind
refactor risk score 1.5 of 3, Jev's estimate
2 files changed, +19 -14
Mbin/forge22++++++++--------------
Mtest/scenarios/site-preview.sh11+++++++++++
M bin/forge +8 -14
@@ -2084,7 +2084,7 @@ review_link() {
20842084 say "review #$1: $(review_url "$OWNER/$NAME" "$1")$on"20852085 }20862086 2087-# Extract a site tree into the content store and point its URL at it.2087+# Extract a site tree into the content store (store_tree) and point its URL at it.20882088 deploy_site() {20892089 link=$FORGE_WWW/$120902090 if [ "$2" = "$ZERO" ]; then
@@ -2092,15 +2092,7 @@ deploy_site() {
20922092 [ -z "${FORGE_PAGES_DOMAIN:-}" ] || node "$FORGE_HOME/lib/hosts.ts" unregister "$1" || true20932093 return 020942094 fi2095- tree=$(git rev-parse "$2^{tree}")2096- store=$FORGE_STATE/store/$tree2097- if [ ! -d "$store" ]; then2098- mkdir -p "$store.tmp.$$"2099- git archive "$2" | tar -x -C "$store.tmp.$$"2100- mv "$store.tmp.$$" "$store"2101- fi2102- # A reused tree counts as new, so a concurrent forge gc leaves it alone.2103- touch -c "$store"2095+ store=$(store_tree "$2")21042096 mkdir -p "$(dirname "$link")"21052097 ln -sfn "$store" "$link"21062098 # Its own hostname, when the forge has a pages domain (lib/hosts.ts).
@@ -2136,10 +2128,12 @@ push_site() {
21362128 fi21372129 }21382130 2139-# store_tree <commit>: extract its tree once into the content store, as2140-# deploy_site does, and print where. git archive stamps every file with the2141-# commit's time, so a tree extracted again (after a restore) gets the same2142-# mtimes. A reused tree counts as new, so a concurrent forge gc leaves it.2131+# store_tree <commit>: extract its tree once into the content store,2132+# .forge/store/<tree>/, and print where. Sites link to it (deploy_site),2133+# releases hard-link its files (release_link). git archive stamps every file2134+# with the commit's time, so a tree extracted again (after a restore) gets2135+# the same mtimes. A reused tree counts as new, so a concurrent forge gc,2136+# which spares what changed in its last --age minutes, leaves it alone.21432137 store_tree() {21442138 st_dir=$FORGE_STATE/store/$(git rev-parse "$1^{tree}")21452139 if [ ! -d "$st_dir" ]; then
M test/scenarios/site-preview.sh +11 -0