11import type { TemplateConfig } from "../domain.js"
2+ import { renderEntrypointGitPostPushWrapperInstall } from "./git-post-push-wrapper.js"
23
34const renderAuthLabelResolution = ( ) : string =>
45 String . raw `# 2) Ensure GitHub auth vars are available for SSH sessions.
@@ -129,7 +130,7 @@ const entrypointGitHooksTemplate = String
129130 . raw `# 3) Install global git hooks to protect main/master + managed AGENTS context
130131HOOKS_DIR="/opt/docker-git/hooks"
131132PRE_PUSH_HOOK="$HOOKS_DIR/pre-push"
132- POST_PUSH_HOOK ="$HOOKS_DIR/post-push"
133+ POST_PUSH_ACTION ="$HOOKS_DIR/post-push"
133134mkdir -p "$HOOKS_DIR"
134135
135136cat <<'EOF' > "$PRE_PUSH_HOOK"
@@ -257,16 +258,17 @@ done
257258EOF
258259chmod 0755 "$PRE_PUSH_HOOK"
259260
260- cat <<'EOF' > "$POST_PUSH_HOOK "
261+ cat <<'EOF' > "$POST_PUSH_ACTION "
261262#!/usr/bin/env bash
262263set -euo pipefail
263264
264265# 5) Run session backup after successful push
265266REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
266267cd "$REPO_ROOT"
267268
268- # CHANGE: run session backup in post-push so source commit has already landed in remote
269- # WHY: backups should mirror successfully pushed state and not block push validation
269+ # CHANGE: keep post-push backup logic in a reusable action script
270+ # WHY: git has no client-side post-push hook, so the global git wrapper
271+ # invokes this after a successful git push
270272# REF: issue-192
271273if [ "${ "${" } DOCKER_GIT_SKIP_SESSION_BACKUP:-}" != "1" ]; then
272274 if command -v gh >/dev/null 2>&1; then
@@ -277,7 +279,7 @@ if [ "${"${"}DOCKER_GIT_SKIP_SESSION_BACKUP:-}" != "1" ]; then
277279 BACKUP_SCRIPT="/opt/docker-git/scripts/session-backup-gist.js"
278280 fi
279281 if [ -n "$BACKUP_SCRIPT" ]; then
280- node "$BACKUP_SCRIPT" || echo "[session-backup] Warning: session backup failed (non-fatal)"
282+ DOCKER_GIT_SKIP_POST_PUSH_ACTION=1 node "$BACKUP_SCRIPT" || echo "[session-backup] Warning: session backup failed (non-fatal)"
281283 else
282284 echo "[session-backup] Warning: script not found (expected repo or global path)"
283285 fi
@@ -286,7 +288,9 @@ if [ "${"${"}DOCKER_GIT_SKIP_SESSION_BACKUP:-}" != "1" ]; then
286288 fi
287289fi
288290EOF
289- chmod 0755 "$POST_PUSH_HOOK"
291+ chmod 0755 "$POST_PUSH_ACTION"
292+
293+ ${ renderEntrypointGitPostPushWrapperInstall ( ) }
290294
291295git config --system core.hooksPath "$HOOKS_DIR" || true
292296git config --global core.hooksPath "$HOOKS_DIR" || true`
0 commit comments