diff --git a/hooks/hooks.json b/hooks/hooks.json new file mode 100644 index 0000000..a297439 --- /dev/null +++ b/hooks/hooks.json @@ -0,0 +1,4 @@ +{ + "description": "Gitea connector hooks — push reminder after commits (opt-in)", + "hooks": {} +} diff --git a/hooks/scripts/push-reminder.sh b/hooks/scripts/push-reminder.sh new file mode 100755 index 0000000..3e84b35 --- /dev/null +++ b/hooks/scripts/push-reminder.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# push-reminder.sh — nudges you to push after a commit +# Reads Bash tool output from stdin (JSON), checks if a git commit happened. + +set -euo pipefail + +INPUT=$(cat) +TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // ""') +TOOL_RESULT=$(echo "$INPUT" | jq -r '.tool_result // ""') + +# Only trigger on Bash tool +[[ "$TOOL_NAME" == "Bash" ]] || exit 0 + +# Check if the output looks like a successful git commit +if echo "$TOOL_RESULT" | grep -qE '^\[.+\]\s+\S+'; then + echo '{"decision":"approve","systemMessage":"Commit detected! Friendly reminder: run `gitea push` to send it to git.sethpc.xyz. Unpushed commits are just really elaborate local notes."}' +else + echo '{"decision":"approve"}' +fi