mergegate/scripts/post-commit-issue-update.sh
林 駿甫 (Shunsuke Hayashi) 553eed3b5d [追加] Git hooks: pre-commit ロック検証 + post-commit Issue 自動更新 (#66)
scripts/pre-commit-lock-check.sh:
  - コミット前にファイルロックを検証
  - POLARIS_AGENT_ID 環境変数でエージェント識別
  - ロック保持者以外の変更を exit 1 で拒否

scripts/post-commit-issue-update.sh:
  - コミットメッセージから #N を抽出
  - gh issue comment で自動更新
  - cargo test 結果も添付
  - バックグラウンド実行(コミットをブロックしない)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 07:04:07 +09:00

36 lines
1 KiB
Bash
Executable file

#!/bin/bash
# Polaris: コミット後に関連 Issue を自動更新する post-commit hook
#
# コミットメッセージに (#52, #53) のような Issue 番号があれば、
# 自動で gh issue comment を実行する。
REPO="Miyabi-G-K/miyabi-cli-standalone"
# 直前のコミット情報を取得
COMMIT_HASH=$(git rev-parse --short HEAD)
COMMIT_MSG=$(git log -1 --pretty=%B)
AUTHOR=$(git log -1 --pretty=%an)
# コミットメッセージから Issue 番号を抽出 (#52, #53 等)
ISSUE_NUMS=$(echo "$COMMIT_MSG" | grep -oE '#[0-9]+' | sed 's/#//')
if [ -z "$ISSUE_NUMS" ]; then
exit 0 # Issue 番号がなければ何もしない
fi
# 各 Issue にコメントを投稿
for NUM in $ISSUE_NUMS; do
gh issue comment "$NUM" \
--repo "$REPO" \
--body "✅ **コミット反映**: \`$COMMIT_HASH\` by $AUTHOR
\`\`\`
$COMMIT_MSG
\`\`\`
cargo test: $(cargo test 2>&1 | grep 'test result' | tail -1)" \
2>/dev/null &
done
# バックグラウンドで実行(コミットをブロックしない)
wait