Adds .githooks/pre-commit (secret scan, large-file guard, fast tests), scripts/check-secrets.sh, scripts/agent-commit.sh, scripts/publish.sh and scripts/setup-hooks.sh so every work session leaves a verifiable commit.
49 lines
1.3 KiB
Bash
Executable file
49 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Commit all working-tree changes with a conventional message.
|
|
#
|
|
# Intended for AI work sessions so that every session leaves a trace in git.
|
|
# It stages everything, runs the safety checks, then commits. It does not push;
|
|
# use scripts/publish.sh for that.
|
|
#
|
|
# Usage: scripts/agent-commit.sh "<conventional commit message>"
|
|
#
|
|
# Environment:
|
|
# PHOEBUS_COMMIT_TEST=0 skip the fast test run before committing
|
|
|
|
set -euo pipefail
|
|
|
|
message="${1:-}"
|
|
if [[ -z "$message" ]]; then
|
|
echo "usage: scripts/agent-commit.sh \"<conventional commit message>\"" >&2
|
|
exit 2
|
|
fi
|
|
|
|
root="$(git rev-parse --show-toplevel)"
|
|
cd "$root"
|
|
|
|
if [[ -z "$(git status --porcelain)" ]]; then
|
|
echo "nothing to commit (working tree clean)"
|
|
exit 0
|
|
fi
|
|
|
|
git add -A
|
|
|
|
scripts/check-secrets.sh
|
|
|
|
if [[ "${PHOEBUS_COMMIT_TEST:-1}" == "1" && -x installer/tests/run_tests.sh ]]; then
|
|
echo "running fast test suite..."
|
|
bash installer/tests/run_tests.sh >/tmp/phoebus-agent-commit-tests.log 2>&1 || {
|
|
echo "tests failed; see /tmp/phoebus-agent-commit-tests.log" >&2
|
|
exit 1
|
|
}
|
|
fi
|
|
|
|
echo "staged changes:"
|
|
git diff --cached --stat | tail -n 40
|
|
|
|
# The checks above already ran; skip the hook's duplicate work.
|
|
SKIP_PHOEBUS_HOOKS=1 git commit -m "$message"
|
|
|
|
echo
|
|
echo "committed: $(git log -1 --oneline)"
|
|
echo "push with: scripts/publish.sh"
|