~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/dual-forge-test

Test: one main on two forges

0
0
main
30 lines · 1.3 KB Raw History
#!/usr/bin/env bash
# The queue: every open pull labelled `land`, on either forge, landed
# oldest first, one at a time. A pull that does not land stays open with
# its reason, and loses the label.
set -uo pipefail

GH_REPO=${GH_REPO:-bigmoves/dual-forge-test}
KN_REPO=${KN_REPO:-knotless://chadtmiller.com/dual-forge-test}
here=$(cd "$(dirname "$0")" && pwd)

# Each pull as "<createdAt> <forge> <id>".
pulls() {
  gh pr list -R "$GH_REPO" --label land --state open --json number,createdAt \
    -q '.[] | "\(.createdAt) github \(.number)"'
  knotless pull list "$KN_REPO" -q 'is:open label:land' | while IFS=$'\t' read -r _ _ uri _; do
    author=${uri#at://}; author=${author%%/*}
    pds=$(curl -fsS "https://plc.directory/$author" | jq -r '.service[] | select(.id | endswith("#atproto_pds")) | .serviceEndpoint')
    at=$(curl -fsS "$pds/xrpc/com.atproto.repo.getRecord?repo=$author&collection=dev.knotless.pull&rkey=${uri##*/}" | jq -r .value.createdAt)
    echo "$at knotless $uri"
  done
}

pulls | sort | while read -r _ forge id; do
  if ! "$here/land.sh" "$forge" "$id" </dev/null; then
    case $forge in
      github) gh pr edit "$id" -R "$GH_REPO" --remove-label land >/dev/null ;;
      knotless) knotless pull label "$KN_REPO" "$id" land --undo >/dev/null ;;
    esac
  fi
done