diff --git a/skills/gitlink-quality-gate/scripts/01-collect-prs.sh b/skills/gitlink-quality-gate/scripts/01-collect-prs.sh index cc7bfa0..ff404b4 100644 --- a/skills/gitlink-quality-gate/scripts/01-collect-prs.sh +++ b/skills/gitlink-quality-gate/scripts/01-collect-prs.sh @@ -25,13 +25,16 @@ PRS=$(gitlink-cli pr +list --owner "$OWNER" --repo "$REPO" --state open --format } echo "$PRS" > "$OUTPUT_DIR/prs-open.json" -# 过滤真实 PR(pull_request_status=0 表示打开中的 PR) +# 过滤打开的 PR(status 可能是数字 0 或字符串 "open"/"opened") REAL_PRS=$(echo "$PRS" | node -e " let s=''; process.stdin.on('data',d=>s+=d).on('end',()=>{ - const d=JSON.parse(s).data||[]; - const items=Array.isArray(d)?d:(d.pull_requests||d); - const real=items.filter(p=>(p.pull_request_status||p.status||0)==0); + const d=JSON.parse(s).data||{}; + const items=Array.isArray(d)?d:(d.pulls||d.pull_requests||[]); + const real=items.filter(p=>{ + const st=p.pull_request_status||p.status||''; + return st===0||st==='0'||st==='open'||st==='opened'; + }); process.stdout.write(JSON.stringify(real)); }); " 2>/dev/null || echo "[]") diff --git a/skills/gitlink-quality-gate/scripts/quality-gate-full.sh b/skills/gitlink-quality-gate/scripts/quality-gate-full.sh index e8c499a..184eb9d 100644 --- a/skills/gitlink-quality-gate/scripts/quality-gate-full.sh +++ b/skills/gitlink-quality-gate/scripts/quality-gate-full.sh @@ -27,14 +27,14 @@ echo "▸ Phase 1/4: PR 采集" bash "$SCRIPT_DIR/01-collect-prs.sh" "$OWNER" "$REPO" echo "" -# 读取待审 PR 列表 -PR_LIST="$OUTPUT_DIR/prs-to-review.json" -if [ ! -f "$PR_LIST" ]; then +# 读取待审 PR 列表(用相对路径避免 MSYS 路径问题) +PR_REL="skills/gitlink-quality-gate/scripts/_output/prs-to-review.json" +if [ ! -f "$PR_REL" ]; then echo "[ERROR] 未找到 PR 列表,请先运行 Phase 1" exit 1 fi -PR_COUNT=$(node -e "const d=require('fs').readFileSync('$PR_LIST','utf8');process.stdout.write(String(JSON.parse(d).length))" 2>/dev/null || echo "0") +PR_COUNT=$(node -e "const d=require('fs').readFileSync('$PR_REL','utf8');process.stdout.write(String(JSON.parse(d).length))" 2>/dev/null || echo "0") if [ "$PR_COUNT" -eq 0 ]; then echo "[INFO] 没有待审 PR,流程结束" @@ -45,7 +45,7 @@ echo "[INFO] 共 $PR_COUNT 个 PR 需要审查" # 遍历每个 PR for i in $(seq 0 $((PR_COUNT - 1))); do - PR_ID=$(node -e "const d=require('fs').readFileSync('$PR_LIST','utf8');const items=JSON.parse(d);process.stdout.write(String(items[$i].id))" 2>/dev/null || echo "") + PR_ID=$(node -e "const d=require('fs').readFileSync('$PR_REL','utf8');const items=JSON.parse(d);process.stdout.write(String(items[$i].id))" 2>/dev/null || echo "") if [ -z "$PR_ID" ]; then echo "[WARN] PR #$i: 无法解析 PR ID,跳过"