#!/bin/bash
export GIT_PAGER=cat PAGER=cat
R=gbharg/agents
echo "=== wait for bot re-reviews on c3893b2e2 ==="
for i in $(seq 1 18); do
  N=$(gh api "repos/$R/pulls/804/reviews" -q '[.[] | select(.commit_id|startswith("c3893b2e")) | select(.body|length>40)] | length')
  echo "poll $i: $N substantive reviews on c3893b2e2"
  if [ "$N" -ge 3 ]; then break; fi
  sleep 10
done
echo "=== bodies ==="
gh api "repos/$R/pulls/804/reviews" -q '.[] | select(.commit_id|startswith("c3893b2e")) | select(.body|length>40) | "\n===== \(.user.login) [\(.state)] =====\n\(.body)"'
echo "=== new line comments on c3893b2e ==="
gh api "repos/$R/pulls/804/comments" -q '.[] | select(.commit_id|startswith("c3893b2e")) | select(.user.login|endswith("[bot]")) | "\n--- \(.user.login) \(.path):\(.line) ---\n\(.body)"'
echo "DONE_S13"
