| 1 | #!/usr/bin/env bash |
| 2 | # Re-request the GitHub Copilot reviewer on a PR. |
| 3 | # |
| 4 | # Copilot does not react to comments. It re-runs only when re-added as a |
| 5 | # requested reviewer. Calling this after pushing is the right way to get a |
| 6 | # follow-up Copilot review. |
| 7 | # |
| 8 | # Usage: |
| 9 | # trigger-copilot.sh <pr-number> |
| 10 | |
| 11 | set -euo pipefail |
| 12 | |
| 13 | # shellcheck source=./_lib.sh |
| 14 | # shellcheck disable=SC1091 |
| 15 | source "$(dirname "$0")/_lib.sh" |
| 16 | pr_require_gh |
| 17 | |
| 18 | PR="${1:?usage: $0 <pr-number>}" |
| 19 | pr_require_numeric "${PR}" |
| 20 | SLUG="$(pr_require_slug)" |
| 21 | |
| 22 | echo -e "${PR_GRAY}[trigger-copilot] PR ${SLUG}#${PR}: re-add @copilot as reviewer${PR_NC}" >&2 |
| 23 | |
| 24 | # Force a fresh review run by removing then re-adding the reviewer. |
| 25 | # `--remove-reviewer @copilot` returns non-zero when copilot is NOT |
| 26 | # currently a requested reviewer (nothing to remove); we ignore that exit |
| 27 | # so the subsequent `--add-reviewer` always runs and triggers the review. |
| 28 | gh pr edit "${PR}" --repo "${SLUG}" --remove-reviewer "@copilot" >/dev/null 2>&1 || true |
| 29 | gh pr edit "${PR}" --repo "${SLUG}" --add-reviewer "@copilot" |
| 30 | echo -e "${PR_GREEN}[trigger-copilot] @copilot re-requested.${PR_NC}" >&2 |