Files
jsc-marketplace/plugins/herdr/skills/gitea-issue/scripts/pr-wait.sh
T
rootandClaude Sonnet 5.5 64c748922b refactor: 將 herdr-issue 併入 herdr 外掛並改名為 gitea-issue
指令由 /herdr-issue:herdr-issue 改為 /herdr:gitea-issue,herdr 升至 0.0.2。

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-13 07:40:33 +00:00

26 lines
1.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 用法:pr-wait.sh <owner/repo> <N>
# 阻塞到 head 為 issue-N 的 PR 有衝突、被關閉或合併,或議題被關閉。
# 最後一行印出原因:conflict | closed | merged | issue-closed
source "$(dirname "$0")/lib.sh"
REPO="${1:?}"; N="${2:?用法:pr-wait.sh <owner/repo> <N>}"
while :; do
read -r PR STATE MERGEABLE <<<"$(pr_for_issue "$REPO" "$N")" || true
if [ -z "${PR:-}" ]; then
echo "還沒有 head 為 issue-$N 的 PR,$INTERVAL 秒後再查"
else
case "$STATE" in
merged) echo "PR #$PR 已合併"; echo merged; exit 0 ;;
closed) echo "PR #$PR 被關閉(未合併)"; echo closed; exit 0 ;;
open)
if [ "$MERGEABLE" = "false" ]; then
sleep 60
read -r _ _ AGAIN <<<"$(pr_for_issue "$REPO" "$N")"
if [ "$AGAIN" = "false" ]; then echo "PR #$PR 與 main 有衝突"; echo conflict; exit 0; fi
fi ;;
esac
fi
if [ "$(issue_state "$REPO" "$N")" = "closed" ]; then echo "議題 #$N 已關閉"; echo issue-closed; exit 0; fi
sleep "$INTERVAL"
done