diff --git a/scripts/save.sh b/scripts/save.sh new file mode 100755 index 0000000..92adaaf --- /dev/null +++ b/scripts/save.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Commit all current changes and push to Gitea. Used to snapshot every +# change to the Command Center so we can always roll back. +# +# Usage: scripts/save.sh "commit message" +set -euo pipefail + +cd "$(dirname "$0")/.." + +MSG="${*:-}" +if [[ -z "$MSG" ]]; then + MSG="checkpoint: $(date '+%Y-%m-%d %H:%M:%S')" +fi + +if [[ -z "$(git status --porcelain)" ]]; then + echo "Nothing to commit; working tree clean." + exit 0 +fi + +git add -A +git commit -m "$MSG" +git push origin "$(git rev-parse --abbrev-ref HEAD)" +echo "Saved + pushed: $MSG"