@plot-pm/board 0.26.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board-server.mjs +411 -310
- package/package.json +1 -1
- package/plot-config.sh +12 -0
- package/plot-dispatch.sh +10 -7
- package/plot-host.sh +63 -94
package/package.json
CHANGED
package/plot-config.sh
CHANGED
|
@@ -241,6 +241,18 @@
|
|
|
241
241
|
# release workflow cannot raise the `default-branch-red`
|
|
242
242
|
# hold or the board's red-branch status. Names match a run's
|
|
243
243
|
# workflow name exactly. Absent = every workflow's runs.
|
|
244
|
+
# Merge checks comma-separated check names (a job's check run or a
|
|
245
|
+
# status context, `validate`) that `plot-ask.mjs merge`
|
|
246
|
+
# and fleetd's merge arm require to have a completed
|
|
247
|
+
# `success` on the pinned head. A named check with no run
|
|
248
|
+
# on the head, or a queued or running one, reads
|
|
249
|
+
# `pending` and refuses `checks-not-green`; of several
|
|
250
|
+
# completed runs of one name, the latest decides. Name the job
|
|
251
|
+
# that aggregates the selected jobs: a re-run removes a
|
|
252
|
+
# job from the rollup until it runs again, so the rest of
|
|
253
|
+
# the rollup can read green without it. Bitbucket reports
|
|
254
|
+
# no check runs, so a named check refuses there. Absent =
|
|
255
|
+
# no named check is required.
|
|
244
256
|
# Jenkins instance the slug or URL passed to a Jenkins CLI's -I flag.
|
|
245
257
|
# Read back by /plot-board-setup to verify auth against
|
|
246
258
|
# the right instance — without it the only runnable
|
package/plot-dispatch.sh
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Plot helper: hand one slice + its brief to the registry per eligible branch.
|
|
3
3
|
# Usage: plot-dispatch.sh [--dry-run] [--no-start] [--no-brief] [--offline]
|
|
4
|
-
# [--max N] [--allow-local] <slug>
|
|
4
|
+
# [--max N] [--branch <br>] [--allow-local] <slug>
|
|
5
5
|
# plot-dispatch.sh --start [N] [--dry-run]
|
|
6
6
|
# plot-dispatch.sh --migrate [--yes] [--max N]
|
|
7
7
|
# plot-dispatch.sh --release <branch>
|
|
@@ -86,6 +86,8 @@
|
|
|
86
86
|
# written when the plan was drafted. A charter this clone does
|
|
87
87
|
# not hold is REPORTED and dispatched anyway; see
|
|
88
88
|
# `plan_declared_agent`.
|
|
89
|
+
# --branch <br> hand over only <br>, one branch of the plan; any other
|
|
90
|
+
# eligible branch is left in the queue.
|
|
89
91
|
# <slug> the plan to fan out
|
|
90
92
|
# Output: one line per branch, each optionally followed by an indented
|
|
91
93
|
# `in flight:` line naming a branch that already holds files, then the
|
|
@@ -340,6 +342,8 @@ while [ $# -gt 0 ]; do
|
|
|
340
342
|
-*) echo "plot-dispatch: --agent needs a charter name, got '$agent'" >&2; exit 1 ;;
|
|
341
343
|
esac
|
|
342
344
|
shift ;;
|
|
345
|
+
# `--branch <br>` hands over that one branch of the plan and no other.
|
|
346
|
+
--branch) only_branch="${2:?--branch needs a branch name}"; shift ;;
|
|
343
347
|
--max) max="${2:?--max needs a value}"
|
|
344
348
|
case "$max" in
|
|
345
349
|
''|*[!0-9]*) echo "plot-dispatch: --max needs a number, got '$max'" >&2; exit 1 ;;
|
|
@@ -348,10 +352,10 @@ while [ $# -gt 0 ]; do
|
|
|
348
352
|
# THE RANGE MOVED WITH THE HEADER IT PRINTS. It ended at `<slug>` and still
|
|
349
353
|
# does; adding `--agent` above pushed that line from 59 to 69, and
|
|
350
354
|
# documenting the plan-declared kind pushed it from 69 to 78, and
|
|
351
|
-
# `--release` pushed it from 78 to 91. Two records
|
|
355
|
+
# `--release` pushed it from 78 to 91, and `--branch` from 89 to 91. Two records
|
|
352
356
|
# of one fact, and nothing compares them — a stale number here silently
|
|
353
357
|
# truncates the help rather than failing, so it is checked by a test.
|
|
354
|
-
-h|--help) sed -n '2,
|
|
358
|
+
-h|--help) sed -n '2,91p' "$0"; exit 0 ;;
|
|
355
359
|
*) slug="$1" ;;
|
|
356
360
|
esac
|
|
357
361
|
shift
|
|
@@ -3492,7 +3496,6 @@ work_in_flight() { # $1=branch to exclude (the candidate)
|
|
|
3492
3496
|
# rather than a map. Sorted output keeps the report stable between runs.
|
|
3493
3497
|
git for-each-ref --format='%(refname:short)' refs/heads/ </dev/null 2>/dev/null \
|
|
3494
3498
|
| while read -r br; do
|
|
3495
|
-
[ -n "$br" ] || continue
|
|
3496
3499
|
[ "$br" = "$exclude" ] && continue
|
|
3497
3500
|
[ "$br" = "$MAIN" ] && continue
|
|
3498
3501
|
files=$( { committed_files "$br"; uncommitted_files "$(worktree_for "$br")"; } \
|
|
@@ -3560,8 +3563,8 @@ run_waits_preflight
|
|
|
3560
3563
|
# set once. (`--next` would loop forever here: without a claim it keeps
|
|
3561
3564
|
# returning the same branch.)
|
|
3562
3565
|
if [ "$dry_run" = 1 ]; then
|
|
3566
|
+
# The list below drops empty lines (`grep -v '^$'`), so every `br` names a branch.
|
|
3563
3567
|
while read -r br; do
|
|
3564
|
-
[ -n "$br" ] || continue
|
|
3565
3568
|
# The gate, BEFORE the "would dispatch" line — this loop's whole output is
|
|
3566
3569
|
# a prediction, and predicting a dispatch the real run refuses is the
|
|
3567
3570
|
# failure the gate exists to stop.
|
|
@@ -3583,7 +3586,7 @@ if [ "$dry_run" = 1 ]; then
|
|
|
3583
3586
|
# branch the scan DID offer (its host call failed where the preflight's
|
|
3584
3587
|
# succeeded) must be dispatched once, not twice.
|
|
3585
3588
|
done < <({ "$script_dir/plot-fleet-scan.sh" $offline --list-eligible "$slug" 2>/dev/null
|
|
3586
|
-
printf '%s\n' ${waits_freed[@]+"${waits_freed[@]}"}; } | grep -v '^$' | sort -u)
|
|
3589
|
+
printf '%s\n' ${waits_freed[@]+"${waits_freed[@]}"}; } | grep -v '^$' | sort -u | awk -v b="${only_branch:-}" 'b == "" || $0 == b')
|
|
3587
3590
|
# A dry run starts nothing BY CONSTRUCTION, so its `started=0` carries no
|
|
3588
3591
|
# information about the config — reporting "no workers started" here would be
|
|
3589
3592
|
# true and useless, and would train the reader to skip the line on the real
|
|
@@ -3632,7 +3635,7 @@ while IFS= read -r _line; do
|
|
|
3632
3635
|
fan_out+=("$_line")
|
|
3633
3636
|
done < <({ "$script_dir/plot-fleet-scan.sh" $offline --list-eligible "$slug" 2>/dev/null
|
|
3634
3637
|
[ "$allow_waiting" = 1 ] && printf '%s\n' ${waits_freed[@]+"${waits_freed[@]}"}
|
|
3635
|
-
:; } | grep -v '^$' | sort -u)
|
|
3638
|
+
:; } | grep -v '^$' | sort -u | awk -v b="${only_branch:-}" 'b == "" || $0 == b')
|
|
3636
3639
|
|
|
3637
3640
|
for branch in ${fan_out[@]+"${fan_out[@]}"}; do
|
|
3638
3641
|
[ "$max" -gt 0 ] && [ "$n_dispatched" -ge "$max" ] && break
|
package/plot-host.sh
CHANGED
|
@@ -133,8 +133,10 @@
|
|
|
133
133
|
# time — `commit-status` writes that status
|
|
134
134
|
# through `plot-bitbucket-commit-status.mjs`.
|
|
135
135
|
# EXIT 3 is the question failing.
|
|
136
|
-
# pr-create --title T [--body B] [--base BR] [--head BR] [--draft]
|
|
137
|
-
# create a PR, print its URL
|
|
136
|
+
# pr-create --title T [--body B | --body-file F] [--base BR] [--head BR] [--draft]
|
|
137
|
+
# create a PR, print its URL. GitHub
|
|
138
|
+
# creates it over REST (`POST pulls`), which
|
|
139
|
+
# spends `core` and never GraphQL.
|
|
138
140
|
# pr-merge <number> [--squash] [--delete-branch] --match-head <sha>
|
|
139
141
|
# merge the PR. --match-head is
|
|
140
142
|
# mandatory on every backend. bitbucket
|
|
@@ -529,17 +531,12 @@
|
|
|
529
531
|
# The transition id is LOOKED UP, never guessed:
|
|
530
532
|
# ids are per workflow and per issue, so a
|
|
531
533
|
# hardcoded one writes to the wrong column.
|
|
532
|
-
# pr-body <number> --body B
|
|
533
|
-
#
|
|
534
|
-
#
|
|
535
|
-
#
|
|
536
|
-
#
|
|
537
|
-
#
|
|
538
|
-
# read Remaining 1236, Used 3764, and reproduced
|
|
539
|
-
# 2026-09-02 against a header's 2732. NOTHING
|
|
540
|
-
# ROUTES ON IT any more — `gh_route` reads the
|
|
541
|
-
# budget record, which is written from response
|
|
542
|
-
# headers. Prefer `limit`.
|
|
534
|
+
# pr-body <number> [--body B | --body-file F]
|
|
535
|
+
# with no flag, print the PR description;
|
|
536
|
+
# with one, replace it. GitHub replaces
|
|
537
|
+
# it over REST (`PATCH pulls/<n>`), which
|
|
538
|
+
# spends `core` and never GraphQL. --body-file
|
|
539
|
+
# reads the body from a file, on both ops.
|
|
543
540
|
# limit what is this connector's limit, and how well
|
|
544
541
|
# does it know it? One JSON line per metered
|
|
545
542
|
# bucket: {"connector","bucket","limit",
|
|
@@ -727,7 +724,9 @@ MERGEABLE_OF='def mergeable_of: if .mergeable == "CONFLICTING" or .mergeable ==
|
|
|
727
724
|
|
|
728
725
|
# THE ONE PROJECTION of a GraphQL-shaped PR into `pr-state`'s printed line, read by
|
|
729
726
|
# the GraphQL arm and by `rest_pr_state`, so the two transports print one shape.
|
|
730
|
-
|
|
727
|
+
# `checkRuns` carries every rollup item unfolded, so the merge controller can
|
|
728
|
+
# require a named check (`Merge checks`) that the folded `checks` word cannot see.
|
|
729
|
+
PR_STATE_OF='{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),head:(.headRefName // ""),headSha:(.headRefOid // ""),base:(.baseRefName // ""),checks:checks_of,ciChecks:ci_checks_of,checkRuns:[.statusCheckRollup[]? | {name:(.name // .context // ""),status:(.status // .state // ""),conclusion:(.conclusion // ""),at:(.startedAt // "")}],checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}'
|
|
731
730
|
|
|
732
731
|
# Exit 5 — the host refused to answer FOR NOW. A rate limit, primary or
|
|
733
732
|
# secondary: nothing is broken, nothing needs fixing, and the same question
|
|
@@ -2444,9 +2443,9 @@ graphql_budget_spent() {
|
|
|
2444
2443
|
# pr-state both transports. The only op with a REST fallback
|
|
2445
2444
|
# written, so the only one where the budget can change the
|
|
2446
2445
|
# answer.
|
|
2447
|
-
#
|
|
2446
|
+
# limit REST-only BY NATURE rather than by omission. It is
|
|
2448
2447
|
# reached through `gh api`, which is REST's transport.
|
|
2449
|
-
#
|
|
2448
|
+
# It spends a GraphQL call to read its own headers —
|
|
2450
2449
|
# the call it makes is GraphQL, the route to it is not.
|
|
2451
2450
|
# * GraphQL-only. Ten ops, and this is where "every op
|
|
2452
2451
|
# consults the router" is honest rather than decorative:
|
|
@@ -2482,7 +2481,7 @@ graphql_budget_spent() {
|
|
|
2482
2481
|
gh_route() { # $1=op → graphql|rest
|
|
2483
2482
|
case "${1:-}" in
|
|
2484
2483
|
# REST-only: no GraphQL route exists to choose, so nothing is consulted.
|
|
2485
|
-
|
|
2484
|
+
limit|pr-create|pr-body)
|
|
2486
2485
|
printf 'rest\n'
|
|
2487
2486
|
;;
|
|
2488
2487
|
# Both transports implemented — the one op where the reasons apply.
|
|
@@ -2548,13 +2547,27 @@ rest_pr_state() { # $1=owner/repo $2=PR number or branch; returns 3 when the bra
|
|
|
2548
2547
|
else pr="$(gh_api_harvest "repos/$1/pulls?head=${1%%/*}:$2&state=all&per_page=1")" || return 1; pr="$(jq -ce '.[0]' <<<"$pr")" || return 3; fi
|
|
2549
2548
|
sha="$(jq -r '.head.sha // ""' <<<"$pr")"
|
|
2550
2549
|
ck="$(gh_api_harvest "repos/$1/commits/$sha/check-runs?per_page=100")" && st="$(gh_api_harvest "repos/$1/commits/$sha/status?per_page=100")" || return 2
|
|
2551
|
-
jq -cs "$CHECKS_OF$MERGEABLE_OF"'.[0] as $p | (.[1].check_runs // []) as $c | (.[2].statuses // []) as $s | (($p.merged == true) or ($p.merged_at != null)) as $m | {number: $p.number, state: (if $m then "MERGED" else ($p.state // "" | ascii_upcase) end), isDraft: ($p.draft // false), url: ($p.html_url // ""), mergeCommit: (if $m then {oid: ($p.merge_commit_sha // "")} else null end), headRefName: ($p.head.ref // ""), headRefOid: ($p.head.sha // ""), baseRefName: ($p.base.ref // ""), mergedAt: ($p.merged_at // ""), mergeable: (if $p.mergeable == true then "MERGEABLE" elif $p.mergeable == false then "CONFLICTING" else "UNKNOWN" end), mergeStateStatus: (($p.mergeable_state // "") | ascii_upcase), statusCheckRollup: ([$c[] | {name, status: ((.status // "") | ascii_upcase), conclusion: ((.conclusion // "") | ascii_upcase)}] + [$s[] | {context, state: ((.state // "") | ascii_upcase)}] + (if ((.[1].total_count // 0) > ($c | length)) or ((.[2].total_count // 0) > ($s | length)) then [{status: "QUEUED"}] else [] end))} |'"$PR_STATE_OF" <<<"$pr$ck$st"
|
|
2550
|
+
jq -cs "$CHECKS_OF$MERGEABLE_OF"'.[0] as $p | (.[1].check_runs // []) as $c | (.[2].statuses // []) as $s | (($p.merged == true) or ($p.merged_at != null)) as $m | {number: $p.number, state: (if $m then "MERGED" else ($p.state // "" | ascii_upcase) end), isDraft: ($p.draft // false), url: ($p.html_url // ""), mergeCommit: (if $m then {oid: ($p.merge_commit_sha // "")} else null end), headRefName: ($p.head.ref // ""), headRefOid: ($p.head.sha // ""), baseRefName: ($p.base.ref // ""), mergedAt: ($p.merged_at // ""), mergeable: (if $p.mergeable == true then "MERGEABLE" elif $p.mergeable == false then "CONFLICTING" else "UNKNOWN" end), mergeStateStatus: (($p.mergeable_state // "") | ascii_upcase), statusCheckRollup: ([$c[] | {name, status: ((.status // "") | ascii_upcase), conclusion: ((.conclusion // "") | ascii_upcase), startedAt: (.started_at // "")}] + [$s[] | {context, state: ((.state // "") | ascii_upcase), startedAt: (.created_at // "")}] + (if ((.[1].total_count // 0) > ($c | length)) or ((.[2].total_count // 0) > ($s | length)) then [{status: "QUEUED"}] else [] end))} |'"$PR_STATE_OF" <<<"$pr$ck$st"
|
|
2552
2551
|
}
|
|
2553
2552
|
|
|
2554
2553
|
# `owner/repo` from the `origin` URL, with no host call. An `ssh://` URL may carry
|
|
2555
2554
|
# a port after the host, and an scp-style remote splits host and path at its first
|
|
2556
2555
|
# colon. Prints nothing and exits 1 where the URL names no `owner/repo`.
|
|
2557
2556
|
gh_origin_slug() { git config --get remote.origin.url | sed -E 's#\.git/?$##; s#^.*[:/]([^/:]+/[^/:]+)$#\1#' | grep -E '^[^/]+/[^/]+$'; }
|
|
2557
|
+
# THE PR TEXT FLAGS of `pr-create` and `pr-body`, parsed in one place. `--body-file`
|
|
2558
|
+
# reads the body from a file, so a long body never rides on the command line: on
|
|
2559
|
+
# 2026-11-14 a hook refused a long inline `--body` for agents in isolated worktrees.
|
|
2560
|
+
pr_text_args() { # $1=op, then its flags → sets title, body, base, head, draft
|
|
2561
|
+
local op="$1"; shift; title=""; body=""; base=""; head=""; draft=""
|
|
2562
|
+
while [ $# -gt 0 ]; do
|
|
2563
|
+
case "$1" in
|
|
2564
|
+
--title|--body|--base|--head) printf -v "${1#--}" '%s' "${2:?}"; shift 2 ;;
|
|
2565
|
+
--body-file) body="$(cat -- "${2:?}" 2>/dev/null)" || die "$op: cannot read $2"; shift 2 ;;
|
|
2566
|
+
--draft) draft=1; shift ;;
|
|
2567
|
+
*) die "$op: unknown arg $1" ;;
|
|
2568
|
+
esac
|
|
2569
|
+
done
|
|
2570
|
+
}
|
|
2558
2571
|
|
|
2559
2572
|
# `gh` as the merger identity where a Merger app token was minted, as the
|
|
2560
2573
|
# signed-in one where none was. The token goes into `GH_TOKEN` only.
|
|
@@ -4384,23 +4397,20 @@ case "$op" in
|
|
|
4384
4397
|
|| die3 "pr-review: the read failed" ;;
|
|
4385
4398
|
|
|
4386
4399
|
pr-create)
|
|
4387
|
-
|
|
4388
|
-
while [ $# -gt 0 ]; do
|
|
4389
|
-
case "$1" in
|
|
4390
|
-
--title) title="${2:?}"; shift 2 ;;
|
|
4391
|
-
--body) body="${2:?}"; shift 2 ;;
|
|
4392
|
-
--base) base="${2:?}"; shift 2 ;;
|
|
4393
|
-
--head) head="${2:?}"; shift 2 ;;
|
|
4394
|
-
--draft) draft=1; shift ;;
|
|
4395
|
-
*) die "pr-create: unknown arg $1" ;;
|
|
4396
|
-
esac
|
|
4397
|
-
done
|
|
4400
|
+
pr_text_args pr-create "$@"
|
|
4398
4401
|
[ -n "$title" ] || die "pr-create needs --title"
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4402
|
+
# GITHUB OPENS THE PR OVER REST, `POST repos/<origin slug>/pulls`, and prints
|
|
4403
|
+
# its `html_url` as `gh pr create` printed its URL. `gh pr create` spends
|
|
4404
|
+
# GraphQL: on 2026-11-13 it failed three times at 0 of 5000 GraphQL while
|
|
4405
|
+
# REST held more than 4600 of 5000. The owner/repo is the origin remote's,
|
|
4406
|
+
# as `pr-merge` reads it, never `gh`'s default repo. REST needs a base and a
|
|
4407
|
+
# head where `gh pr create` filled them in: a missing `--head` is the
|
|
4408
|
+
# current branch, and a missing `--base` is this script's `default-branch`.
|
|
4409
|
+
# `pipefail` makes a failed POST the op's exit code, with `gh`'s own words.
|
|
4410
|
+
if [ "$be" = "github" ]; then
|
|
4411
|
+
slug="$(gh_origin_slug)" && head="${head:-$(git symbolic-ref --short HEAD)}" && base="${base:-$(bash "$here/plot-host.sh" default-branch)}" || die3 "pr-create: no owner/repo on origin or no head branch; nothing was opened"
|
|
4412
|
+
gh_api_harvest -X POST "repos/$slug/pulls" -f title="$title" -f head="$head" -f base="$base" -f body="$body" -F draft="$([ -n "$draft" ] && echo true || echo false)" | jq -r '.html_url'
|
|
4413
|
+
else bb pr create --title "$title" --body "$body" ${base:+--base "$base"} ${head:+--head "$head"} ${draft:+--draft}; fi
|
|
4404
4414
|
;;
|
|
4405
4415
|
|
|
4406
4416
|
pr-merge)
|
|
@@ -5769,66 +5779,25 @@ case "$op" in
|
|
|
5769
5779
|
printf '%s' "$body" | jq -c '.[] | {name, released: (.released // false), releaseDate: (.releaseDate // null)}' || exit 3 ;;
|
|
5770
5780
|
|
|
5771
5781
|
pr-body)
|
|
5772
|
-
num="${1:?pr-body needs a PR number}"; shift
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
[ -n "$body" ] || die "pr-body needs --body"
|
|
5780
|
-
"$cli" pr edit "$num" --body "$body"
|
|
5781
|
-
;;
|
|
5782
|
-
|
|
5783
|
-
rate-limit)
|
|
5784
|
-
# Report the remaining API budget, per API. GitHub has TWO separate budgets
|
|
5785
|
-
# (GraphQL and REST/core), and exhausting one says nothing about the other.
|
|
5786
|
-
# Bitbucket has a single budget and no way to query it, so it reports unknown.
|
|
5787
|
-
#
|
|
5788
|
-
# Output: JSON object with the remaining budget per API:
|
|
5789
|
-
# {"graphql":{"remaining":N,"limit":N,"reset":N},"core":{"remaining":N,"limit":N,"reset":N}}
|
|
5790
|
-
# where N is a number, or each field is "unknown" when the host cannot answer.
|
|
5791
|
-
#
|
|
5792
|
-
# `reset` is epoch seconds — when the budget resets. A caller that wants
|
|
5793
|
-
# "time until reset" computes it from now.
|
|
5794
|
-
#
|
|
5795
|
-
# The call itself is FREE — `gh api rate_limit` consumes neither bucket.
|
|
5796
|
-
# Measured 2026-08-27: three consecutive readings, all `used=0`.
|
|
5797
|
-
#
|
|
5798
|
-
# This op REPORTS; it does not decide. A caller that wants to fall back when
|
|
5799
|
-
# one budget is spent reads this, compares remaining to zero, and acts.
|
|
5800
|
-
if [ "$be" = "github" ]; then
|
|
5801
|
-
if out="$(gh api rate_limit 2>"$HOST_ERR")"; then
|
|
5802
|
-
rm -f "$HOST_ERR"
|
|
5803
|
-
# The payload has `resources.graphql` and `resources.core`, each with
|
|
5804
|
-
# `remaining`, `limit`, and `reset`. Extract the two we care about.
|
|
5805
|
-
jq -c '{
|
|
5806
|
-
graphql: {
|
|
5807
|
-
remaining: .resources.graphql.remaining,
|
|
5808
|
-
limit: .resources.graphql.limit,
|
|
5809
|
-
reset: .resources.graphql.reset
|
|
5810
|
-
},
|
|
5811
|
-
core: {
|
|
5812
|
-
remaining: .resources.core.remaining,
|
|
5813
|
-
limit: .resources.core.limit,
|
|
5814
|
-
reset: .resources.core.reset
|
|
5815
|
-
}
|
|
5816
|
-
}' <<<"$out"
|
|
5817
|
-
else
|
|
5818
|
-
host_err
|
|
5819
|
-
# The host could not be asked. Report unknown rather than failing outright,
|
|
5820
|
-
# because this is informational — a caller that cannot read the budget
|
|
5821
|
-
# should proceed with the default path, not error out.
|
|
5822
|
-
echo '{"graphql":{"remaining":"unknown","limit":"unknown","reset":"unknown"},"core":{"remaining":"unknown","limit":"unknown","reset":"unknown"}}'
|
|
5823
|
-
echo "plot-host: rate-limit query failed: $err" >&2
|
|
5824
|
-
fi
|
|
5825
|
-
else
|
|
5826
|
-
# Bitbucket has no budget reporting. `unknown` is not `zero` — a host that
|
|
5827
|
-
# cannot answer the budget question must report unknown, because zero means
|
|
5828
|
-
# *spent*, and a caller that reads "cannot ask" as "exhausted" will take
|
|
5829
|
-
# the expensive fallback path forever.
|
|
5830
|
-
echo '{"graphql":{"remaining":"unknown","limit":"unknown","reset":"unknown"},"core":{"remaining":"unknown","limit":"unknown","reset":"unknown"}}'
|
|
5782
|
+
num="${1:?pr-body needs a PR number}"; shift
|
|
5783
|
+
# WITH NO FLAG IT READS: it prints the PR's body, "" where it has none.
|
|
5784
|
+
# GitHub reads `GET pulls/<n>` over REST; Bitbucket reads `description`.
|
|
5785
|
+
if [ $# -eq 0 ]; then
|
|
5786
|
+
if [ "$be" = "github" ]; then gh_api_harvest "repos/$(gh_origin_slug)/pulls/$num" | jq -r '.body // ""'
|
|
5787
|
+
else bb_require_json; bb pr view "$num" --json | jq -r '.description // ""'; fi
|
|
5788
|
+
exit
|
|
5831
5789
|
fi
|
|
5790
|
+
pr_text_args pr-body "$@"
|
|
5791
|
+
[ -z "$title$base$head$draft" ] || die "pr-body takes only --body or --body-file"
|
|
5792
|
+
[ -n "$body" ] || die "pr-body needs --body or --body-file"
|
|
5793
|
+
# GITHUB REPLACES THE BODY OVER REST, `PATCH repos/<origin slug>/pulls/<n>`,
|
|
5794
|
+
# and prints its `html_url` as `gh pr edit` printed the URL. `gh pr edit`
|
|
5795
|
+
# spends GraphQL: on 2026-11-14 it failed twice with "GraphQL: API rate limit
|
|
5796
|
+
# already exceeded" while REST held budget. `pr-create` takes the same route.
|
|
5797
|
+
if [ "$be" = "github" ]; then
|
|
5798
|
+
slug="$(gh_origin_slug)" || die3 "pr-body: no owner/repo on origin; nothing was written"
|
|
5799
|
+
gh_api_harvest -X PATCH "repos/$slug/pulls/$num" -f body="$body" | jq -r '.html_url'
|
|
5800
|
+
else bb pr edit "$num" --body "$body"; fi
|
|
5832
5801
|
;;
|
|
5833
5802
|
|
|
5834
5803
|
limit)
|
|
@@ -6059,6 +6028,6 @@ case "$op" in
|
|
|
6059
6028
|
gh_edit_or_post_comment "$cid" pr "$num" "${2:?pr-comment needs a body}" || gh_fail; rm -f "$HOST_ERR" ;;
|
|
6060
6029
|
|
|
6061
6030
|
*)
|
|
6062
|
-
die "unknown op '$op' (backend|default-branch|pr-state|pr-create|pr-merge|pr-list|issue-list|issue-view|issue-status|issue-open|issue-label|issue-comment|issue-comment-read|issue-close|version-list|pr-body|pr-review|
|
|
6031
|
+
die "unknown op '$op' (backend|default-branch|pr-state|pr-create|pr-merge|pr-list|issue-list|issue-view|issue-status|issue-open|issue-label|issue-comment|issue-comment-read|issue-close|version-list|pr-body|pr-review|limit|ci-limit|spend-rate|commit-status|pr-comment)"
|
|
6063
6032
|
;;
|
|
6064
6033
|
esac
|