From 25251a1202c1311f07172881f7d7ada6af3f25cc Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Sun, 8 Mar 2026 07:37:03 +0000 Subject: feat: stash uncommitted changes before build in deploy script Add --dirty flag to skip stashing behavior. Stashing includes untracked files and uses a trap to ensure changes are popped back on exit. --- scripts/deploy | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/deploy b/scripts/deploy index cc51fc1..5f730cc 100755 --- a/scripts/deploy +++ b/scripts/deploy @@ -1,18 +1,34 @@ #!/bin/bash # deploy — Build and deploy claudomator to /site/doot.terst.org -# Usage: ./scripts/deploy +# Usage: ./scripts/deploy [--dirty] # Example: sudo ./scripts/deploy set -euo pipefail +DIRTY=false +for arg in "$@"; do + if [ "$arg" == "--dirty" ]; then + DIRTY=true + fi +done + FQDN="doot.terst.org" SITE_DIR="/site/${FQDN}" BIN_DIR="${SITE_DIR}/bin" SERVICE="claudomator@${FQDN}.service" REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)" -echo "==> Building claudomator..." cd "${REPO_DIR}" + +STASHED=false +if [ "$DIRTY" = false ] && [ -n "$(git status --porcelain)" ]; then + echo "==> Stashing uncommitted changes..." + git stash push -u -m "Auto-stash before deploy" + STASHED=true + trap 'if [ "$STASHED" = true ]; then echo "==> Popping stash..."; git stash pop; fi' EXIT +fi + +echo "==> Building claudomator..." export GOCACHE="${SITE_DIR}/cache/go-build" export GOPATH="${SITE_DIR}/cache/gopath" mkdir -p "${GOCACHE}" "${GOPATH}" -- cgit v1.2.3