git-local-commit.sh
619 Bytes
#!/bin/bash
set -e
# Hook Scrip: Run AFTER Task
# Context: TASK_ID, EXIT_CODE
if [ "$EXIT_CODE" -ne "0" ]; then
echo "[Hook:Local:Commit] Task Failed ($EXIT_CODE), skipping commit."
exit 0
fi
echo "[Hook:Local:Commit] Task Success. Committing..."
WORK_AREA="/tmp/agent-workspace"
cd $WORK_AREA
# 1. 检查是否有修改
if [ -z "$(git status --porcelain)" ]; then
echo "No changes."
exit 0
fi
# 2. Add & Commit
git add .
git commit -m "feat: task $TASK_ID implemented by $AGENT_NAME"
# 3. Push
BRANCH_NAME="feat/$TASK_ID"
git push origin $BRANCH_NAME
echo "[Hook:Local:Commit] Pushed to $BRANCH_NAME"