@plot-pm/board 0.24.0 → 0.26.0
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 +341 -288
- package/package.json +2 -4
- package/plot-desk-root.sh +38 -12
- package/plot-dispatch.sh +61 -337
- package/plot-host.sh +153 -161
- package/plot-worker-state.sh +69 -93
- package/plot-agent-monitor.sh +0 -570
- package/plot-monitor-subject.sh +0 -245
package/plot-host.sh
CHANGED
|
@@ -111,12 +111,21 @@
|
|
|
111
111
|
# (exit 0) where none merged. The same query
|
|
112
112
|
# `pr-merge-commit` runs. EXIT 3 is the question
|
|
113
113
|
# failing.
|
|
114
|
-
# pr-review <number> one JSON line `{"sha","state","description","time","bypass"}`:
|
|
114
|
+
# pr-review <number> one JSON line `{"sha","state","description","time","bypass","statuses"}`:
|
|
115
115
|
# the PR's head sha, the newest `plot/review`
|
|
116
|
-
# status on it
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
#
|
|
116
|
+
# status on it from ANY writer
|
|
117
|
+
# (`success|failure|pending|error`, or
|
|
118
|
+
# `absent`), that status's description and
|
|
119
|
+
# time (both `""` where state is `absent`),
|
|
120
|
+
# whether a comment starts `review-bypass:`, and
|
|
121
|
+
# `statuses`: every `plot/review` status on the
|
|
122
|
+
# head, newest first, as `{"state",
|
|
123
|
+
# "description","time","writer"}` where
|
|
124
|
+
# `writer` is `creator.login` (`""` where the
|
|
125
|
+
# host names none). GitHub reads every page of
|
|
126
|
+
# the head's statuses. The op reports and
|
|
127
|
+
# decides nothing: `checkedReview` judges
|
|
128
|
+
# `statuses` against the Review app's bot login.
|
|
120
129
|
# Bitbucket reads the same state words from the
|
|
121
130
|
# `plot/review` commit status (SUCCESSFUL,
|
|
122
131
|
# FAILED, INPROGRESS, STOPPED), its
|
|
@@ -635,7 +644,7 @@
|
|
|
635
644
|
# - no auto-merge / merge queues — pr-merge merges immediately or fails
|
|
636
645
|
# - "closed" state is Bitbucket's DECLINED (normalized to CLOSED here)
|
|
637
646
|
# - pr-state by BRANCH resolves via pr-list filtering (one extra call)
|
|
638
|
-
# - draft flag support
|
|
647
|
+
# - draft flag support: `bb pr create --draft`, `bb pr edit <n> --ready`
|
|
639
648
|
# Small-model consumption: structured output, no interpretation, exit 0 with
|
|
640
649
|
# state NONE rather than nonzero on lookup misses.
|
|
641
650
|
|
|
@@ -690,7 +699,7 @@ gh_marker_comment_id() { gh api --paginate "repos/{owner}/{repo}/issues/$1/comme
|
|
|
690
699
|
# EDITS THE COMMENT `$1` HOLDS, OR POSTS `$4` TO `$3` ON `$2` (`issue` or
|
|
691
700
|
# `pr`) — shared by `issue-comment` and `pr-comment`, whose tails differed
|
|
692
701
|
# only in that one word.
|
|
693
|
-
gh_edit_or_post_comment() { if [ -n "$1" ]; then gh api -X PATCH "repos/{owner}/{repo}/issues/comments/$1" -f body="$4" >/dev/null 2>"$HOST_ERR"; else gh
|
|
702
|
+
gh_edit_or_post_comment() { if [ -n "$1" ]; then gh api -X PATCH "repos/{owner}/{repo}/issues/comments/$1" -f body="$4" >/dev/null 2>"$HOST_ERR"; else gh api -X POST "repos/{owner}/{repo}/issues/$3/comments" -f body="$4" >/dev/null 2>"$HOST_ERR"; fi; }
|
|
694
703
|
|
|
695
704
|
# Exit 3 — reserved for "the op itself cannot proceed", distinct from `die`'s
|
|
696
705
|
# generic 1. A Jenkins overlay with no instance to ask is such a case: a config
|
|
@@ -716,6 +725,10 @@ CHECKS_OF='def ck: (.conclusion // "") as $k | (.status // "") as $s | (if $s !=
|
|
|
716
725
|
MERGEABLE_OF='def mergeable_of: if .mergeable == "CONFLICTING" or .mergeable == false or .mergeStateStatus == "DIRTY" or .mergeable_state == "dirty" then "conflicting"
|
|
717
726
|
elif .mergeable == "MERGEABLE" or .mergeable == true then "mergeable" else "unknown" end;'
|
|
718
727
|
|
|
728
|
+
# THE ONE PROJECTION of a GraphQL-shaped PR into `pr-state`'s printed line, read by
|
|
729
|
+
# the GraphQL arm and by `rest_pr_state`, so the two transports print one shape.
|
|
730
|
+
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,checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}'
|
|
731
|
+
|
|
719
732
|
# Exit 5 — the host refused to answer FOR NOW. A rate limit, primary or
|
|
720
733
|
# secondary: nothing is broken, nothing needs fixing, and the same question
|
|
721
734
|
# asked later will be answered.
|
|
@@ -820,7 +833,6 @@ host_cli() { # → the CLI this backend drives, or '' where none is known
|
|
|
820
833
|
case "$1" in
|
|
821
834
|
github) echo "gh" ;;
|
|
822
835
|
bitbucket) echo "bb" ;;
|
|
823
|
-
*) echo "" ;;
|
|
824
836
|
esac
|
|
825
837
|
}
|
|
826
838
|
|
|
@@ -1907,26 +1919,6 @@ jenkins_no_instance() {
|
|
|
1907
1919
|
# estimate for. This draws it one step earlier, for a connector that does not
|
|
1908
1920
|
# exist at all — and `resultOf` (`adapters/run-script.ts:211`) maps exit 4 onto
|
|
1909
1921
|
# `unaskable`, which is the word the build port already answers with.
|
|
1910
|
-
# The Jenkins REST credential: JENKINS_USER + JENKINS_API_TOKEN from the
|
|
1911
|
-
# environment, then `plot_env_file`, then the macOS keychain where `jen`
|
|
1912
|
-
# already stores it — the environment wins outright, same order and the same
|
|
1913
|
-
# both-or-neither rule as `jira_load_env_file`.
|
|
1914
|
-
#
|
|
1915
|
-
# NOT THE KEYCLOAK BEARER. `jen auth token` prints one and Jenkins answers it
|
|
1916
|
-
# with an HTML login redirect — measured 2026-09-10. Jenkins' own API takes
|
|
1917
|
-
# BASIC auth with a user and an API token.
|
|
1918
|
-
#
|
|
1919
|
-
# Prints `user:token` and nothing else, or nothing at all — never the value
|
|
1920
|
-
# on a failure path. Empty means no source held a full pair; the caller turns
|
|
1921
|
-
# that into exit 4, *cannot be asked*.
|
|
1922
|
-
jenkins_rest_credential() { # $1 = the bare host
|
|
1923
|
-
local u="${JENKINS_USER:-}" t="${JENKINS_API_TOKEN:-}" src="the environment" found env_file
|
|
1924
|
-
[ -n "$u" ] || [ -n "$t" ] || { found="$(plot_env_file JENKINS_USER JENKINS_API_TOKEN)"; [ -n "$found" ] && env_file="${found%|*}" && src="${found#*|}.env" && u="$(read_env_var JENKINS_USER "$env_file")" && t="$(read_env_var JENKINS_API_TOKEN "$env_file")"; }
|
|
1925
|
-
[ -n "$u" ] && [ -n "$t" ] && { echo "plot-host: JENKINS_USER and JENKINS_API_TOKEN read from $src" >&2; printf '%s:%s' "$u" "$t"; return 0; }
|
|
1926
|
-
command -v security >/dev/null 2>&1 || return 1; u=$(security find-generic-password -s jen -a "jenkins-user:$1" -w 2>/dev/null) || return 1
|
|
1927
|
-
t=$(security find-generic-password -s jen -a "jenkins-token:$1" -w 2>/dev/null) || return 1
|
|
1928
|
-
[ -n "$u" ] && [ -n "$t" ] || return 1; printf '%s:%s' "$u" "$t"
|
|
1929
|
-
}
|
|
1930
1922
|
|
|
1931
1923
|
# A job path as Jenkins' REST API spells it: every segment under `job/`.
|
|
1932
1924
|
#
|
|
@@ -1943,20 +1935,6 @@ jenkins_job_url_path() { # $1 = job path, $2 = branch or ""
|
|
|
1943
1935
|
printf '%s' "$out"
|
|
1944
1936
|
}
|
|
1945
1937
|
|
|
1946
|
-
# The REST host for the Jenkins slug $1, read off `jen -I <slug> auth status`'s
|
|
1947
|
-
# `Instance:` line rather than reinvented here — `jen` already turns a slug
|
|
1948
|
-
# like `ewz` into `jenkins-ci-ewz.internal.quatico.dev` and keys its stored
|
|
1949
|
-
# credential by that resolved host, so a literal slug sent to `curl` or to
|
|
1950
|
-
# `jenkins_rest_credential` can only fail. Prints nothing and exits 1 when
|
|
1951
|
-
# `jen` is missing, unparseable, or the line is absent; exits 2 when the line
|
|
1952
|
-
# names no parenthesized host. The caller decides what an unresolved host
|
|
1953
|
-
# means, same contract as every other helper here.
|
|
1954
|
-
jenkins_resolve_host() {
|
|
1955
|
-
local line; line=$(jen -I "$1" auth status 2>&1 | grep -iE '^Instance:' | head -1)
|
|
1956
|
-
[ -n "$line" ] || return 1
|
|
1957
|
-
sed -nE 's/.*\(https?:\/\/([^)\/]+).*/\1/p' <<<"$line" | grep . || return 2
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
1938
|
# Every Jenkins build of one job, as a JSON array (newest first), or exit 3
|
|
1961
1939
|
# (no instance) / exit 4 (cannot be asked). Shared by `run-for-sha`,
|
|
1962
1940
|
# `runs-for-sha` and `runs`, so the instance, the credential and the
|
|
@@ -1968,10 +1946,11 @@ jenkins_resolve_host() {
|
|
|
1968
1946
|
# Run it in `$(...)` and read the exit code with `|| exit $?`: it exits rather
|
|
1969
1947
|
# than returns, and a subshell's exit is the code the caller sees.
|
|
1970
1948
|
#
|
|
1971
|
-
#
|
|
1972
|
-
# `
|
|
1973
|
-
#
|
|
1974
|
-
#
|
|
1949
|
+
# Plot reaches Jenkins only through `jen`; `jen api` carries the sha through
|
|
1950
|
+
# `tree=` in one round trip. Measured 2026-09-10: a `jen build list --json`
|
|
1951
|
+
# entry carries no sha, so Jenkins' REST API answers it at
|
|
1952
|
+
# `actions[].lastBuiltRevision.SHA1`, and `jen api <path>` (jen 0.4.0) is the
|
|
1953
|
+
# raw passthrough that reaches it with the proxy's own auth headers.
|
|
1975
1954
|
#
|
|
1976
1955
|
# A BRANCH IS A JOB SEGMENT ON A MULTIBRANCH JOB AND NOT ON A PLAIN ONE, and no
|
|
1977
1956
|
# reading of the configured path says which this is. The multibranch URL is
|
|
@@ -1983,10 +1962,9 @@ jenkins_resolve_host() {
|
|
|
1983
1962
|
# path segment, as `jenkins_build_map` keys it). A multibranch container that
|
|
1984
1963
|
# answers `jobs` and no `builds` has not indexed the branch: an empty history.
|
|
1985
1964
|
#
|
|
1986
|
-
#
|
|
1987
|
-
#
|
|
1988
|
-
#
|
|
1989
|
-
# `builds` test.
|
|
1965
|
+
# A `jen` THAT CANNOT AUTHENTICATE IS *CANNOT BE ASKED*, never *no run*; an
|
|
1966
|
+
# unreachable instance is not an empty history. A refused or redirected
|
|
1967
|
+
# request answers HTML, which fails the `builds` test.
|
|
1990
1968
|
#
|
|
1991
1969
|
# A BRANCH THE MULTIBRANCH JOB NEVER INDEXED IS AN EMPTY HISTORY, NOT A
|
|
1992
1970
|
# REFUSAL. Measured live on ewz-kus-portal: `develop` builds in a separate job
|
|
@@ -2031,8 +2009,8 @@ jenkins_resolve_host() {
|
|
|
2031
2009
|
# the cut silently shrinks the answer — `runs --limit 3` over five builds where
|
|
2032
2010
|
# two are `NOT_BUILT` returning 1 row instead of 3. The over-fetch factor is
|
|
2033
2011
|
# fixed at 3x, uncapped: it costs response BYTES, never an extra round trip or
|
|
2034
|
-
# rate-budget slot (`
|
|
2035
|
-
#
|
|
2012
|
+
# rate-budget slot (the `jen()` wrapper records one ledger row per path
|
|
2013
|
+
# regardless of `limit`), and a single multibranch job's full history is
|
|
2036
2014
|
# small enough that 3x of any realistic `--limit` stays well under what one
|
|
2037
2015
|
# `tree=` query already returns today (measured 2026-09-10: 4855 bytes for
|
|
2038
2016
|
# five builds).
|
|
@@ -2041,35 +2019,24 @@ jenkins_resolve_host() {
|
|
|
2041
2019
|
# is tried first; if it answers real JSON with no `builds` key, Jenkins
|
|
2042
2020
|
# reached the job and simply has no such branch, and the refusal says so.
|
|
2043
2021
|
# Only the root-path retry's container check (above) can turn that into an
|
|
2044
|
-
# empty-history read instead. A host that never answers at all —
|
|
2045
|
-
#
|
|
2046
|
-
# since nothing there proves Jenkins was even reached.
|
|
2022
|
+
# empty-history read instead. A host that never answers at all — a failed
|
|
2023
|
+
# `jen api` request, HTML, empty body — gets the generic "did not answer"
|
|
2024
|
+
# refusal, since nothing there proves Jenkins was even reached.
|
|
2047
2025
|
jenkins_sha_runs() {
|
|
2048
|
-
local op="$1" branch="$2" limit="$3" sha="$4" instance slug
|
|
2026
|
+
local op="$1" branch="$2" limit="$3" sha="$4" instance slug job tree body try path plain="" default_job root_path branch_path branch_answered="" err_tmp err_line
|
|
2049
2027
|
instance="$(jenkins_instance)"; [ -n "$instance" ] || jenkins_no_instance
|
|
2050
2028
|
slug="${instance%%/*}"; job="${instance#*/}"; [ "$job" = "$instance" ] && job=""
|
|
2051
2029
|
default_job=$(bash "$here/plot-config.sh" get "Default branch job" "" 2>/dev/null || true); [ -n "$default_job" ] && [ "$branch" = "$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's#^origin/##')" ] && job="$default_job"
|
|
2052
2030
|
[ -n "${PLOT_JENKINS_JOB:-}" ] && job="$PLOT_JENKINS_JOB"; [ -n "$job" ] || { echo "plot-host: $op — the Jenkins instance names no job path; a sha lives in a job's builds, so it must be <slug>/<job/path>, not a bare host" >&2; exit 4; }
|
|
2053
|
-
# A dotted slug IS a host already, `jen`'s own passthrough rule — only a
|
|
2054
|
-
# bare slug (`ewz`) needs resolving to the host its credential is keyed by.
|
|
2055
|
-
case "$slug" in *.*) host="$slug" ;; *) host="$(jenkins_resolve_host "$slug")" || {
|
|
2056
|
-
[ $? = 2 ] && printf '%s\n' "plot-host: $op — cannot resolve Jenkins instance '$slug' to a host" " \`jen -I $slug auth status\` answered an 'Instance:' line that names no (https://…) host; run it directly to see what it names." >&2 || printf '%s\n' "plot-host: $op — cannot resolve Jenkins instance '$slug' to a host" " \`jen -I $slug auth status\` did not answer an 'Instance:' line; run it directly to see why." >&2
|
|
2057
|
-
exit 4; } ;; esac
|
|
2058
|
-
cred="$(jenkins_rest_credential "$host")" || {
|
|
2059
|
-
echo "plot-host: $op — no Jenkins API credential for '$host'" >&2
|
|
2060
|
-
echo " Jenkins' REST API takes basic auth with an API token, which \`jen auth login\` stores in the login keychain. The Keycloak bearer from \`jen auth token\` is NOT it." >&2
|
|
2061
|
-
exit 4
|
|
2062
|
-
}
|
|
2063
2031
|
tree="tree=builds%5Bnumber,result,building,timestamp,url,actions%5BlastBuiltRevision%5BSHA1,branch%5Bname%5D%5D%5D%5D%7B0,$((limit * 3))%7D"
|
|
2064
2032
|
body=""; root_path="$(jenkins_job_url_path "$job" "")"; branch_path="$(jenkins_job_url_path "$job" "$branch")"
|
|
2065
2033
|
for path in "$branch_path" "$root_path"; do
|
|
2066
|
-
|
|
2067
|
-
try=$(
|
|
2068
|
-
host_slot_give; budget_record_call jenkins ''
|
|
2034
|
+
plot_tmpfile err_tmp host-jenkins-sha-err || { echo "plot-host: $op — no temp file could be made under ${TMPDIR:-/tmp}" >&2; exit 3; }
|
|
2035
|
+
try=$(PLOT_JEN_BOUND_S="${PLOT_JENKINS_SHA_BOUND_S:-30}" jen -I "$slug" api "$path/api/json?$tree" 2>"$err_tmp") || true
|
|
2069
2036
|
if printf '%s' "$try" | jq -e 'has("builds")' >/dev/null 2>&1; then body="$try"; break; fi
|
|
2070
2037
|
# A branch path that came back as REAL JSON (jq could parse and evaluate
|
|
2071
2038
|
# it, just found no `builds` key) means Jenkins answered and indexed no
|
|
2072
|
-
# such branch — distinct from
|
|
2039
|
+
# such branch — distinct from `jen` failing outright or answering HTML,
|
|
2073
2040
|
# where jq's own exit code is 4 (empty input) or 5 (parse error) rather
|
|
2074
2041
|
# than the 1 a successfully-evaluated `false` reports.
|
|
2075
2042
|
[ "$path" = "$branch_path" ] && printf '%s' "$try" | jq -e . >/dev/null 2>&1 && branch_answered=1
|
|
@@ -2083,8 +2050,23 @@ jenkins_sha_runs() {
|
|
|
2083
2050
|
[ "$path" = "$root_path" ] && printf '%s' "$try" | jq -e '._class == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject"' >/dev/null 2>&1 && { body='{"builds":[]}'; break; }
|
|
2084
2051
|
plain=1
|
|
2085
2052
|
done
|
|
2086
|
-
|
|
2087
|
-
|
|
2053
|
+
if [ -z "$body" ]; then
|
|
2054
|
+
if [ -n "$branch_answered" ]; then
|
|
2055
|
+
echo "plot-host: $op — Jenkins has no branch '$branch' indexed for '$job'" >&2
|
|
2056
|
+
else
|
|
2057
|
+
err_line="$(grep -m1 '^error:' "$err_tmp" 2>/dev/null || true)"
|
|
2058
|
+
if grep -qi 'unknown command: api' "$err_tmp" 2>/dev/null; then
|
|
2059
|
+
echo "plot-host: $op — the sha read needs jen 0.4.0 or later with \`api\`" >&2
|
|
2060
|
+
elif grep -qiE 'command not found|no such file or directory' "$err_tmp" 2>/dev/null; then
|
|
2061
|
+
echo "plot-host: $op — \`jen\` is not installed; the sha read needs jen 0.4.0 or later with \`api\`" >&2
|
|
2062
|
+
else
|
|
2063
|
+
printf '%s\n' "plot-host: $op — Jenkins did not answer for Jenkins instance '$slug'" >&2
|
|
2064
|
+
[ -n "$err_line" ] && printf ' jen: %s\n' "$err_line" >&2
|
|
2065
|
+
printf ' Plot reaches Jenkins only through `jen`; run `jen auth login`.\n' >&2
|
|
2066
|
+
fi
|
|
2067
|
+
fi
|
|
2068
|
+
exit 4
|
|
2069
|
+
fi
|
|
2088
2070
|
printf '%s' "$body" | jq -c --arg sha "$sha" --arg job "$job" --arg branch "$branch" --arg plain "$plain" --argjson limit "$limit" 'def headsha($records): ($records | map(select(any(.branches[]; . == $branch))) | first.sha) // (if [$records[].branches[]] | length == 0 then $records | last.sha // "" else "" end);
|
|
2089
2071
|
[ .builds[]
|
|
2090
2072
|
| { records: [ .actions[]? | select(.lastBuiltRevision) | .lastBuiltRevision
|
|
@@ -2152,7 +2134,7 @@ bb_fetch_base_bounded() {
|
|
|
2152
2134
|
GIT_TERMINAL_PROMPT=0 git fetch -q origin "+refs/heads/$base:refs/remotes/origin/$base" 2>/dev/null & pid=$!
|
|
2153
2135
|
( sleep "$BB_FETCH_BOUND_S"; kill -TERM "-$pid" 2>/dev/null ) & watcher=$!
|
|
2154
2136
|
wait "$pid" 2>/dev/null; rc=$?
|
|
2155
|
-
kill "
|
|
2137
|
+
kill -TERM "-$watcher" 2>/dev/null; wait "$watcher" 2>/dev/null; [ "$was_m" = yes ] || set +m
|
|
2156
2138
|
return "$rc"
|
|
2157
2139
|
}
|
|
2158
2140
|
|
|
@@ -2313,7 +2295,7 @@ is_lookup_miss() {
|
|
|
2313
2295
|
# `LC_ALL=C` for the reason `is_lookup_miss` gives: the CLI localises, and an
|
|
2314
2296
|
# English-only matcher would misread every other locale.
|
|
2315
2297
|
is_rate_refusal() {
|
|
2316
|
-
LC_ALL=C grep -qiE 'rate limit|secondary rate|abuse detection|403.*forbidden' <<<"$1"
|
|
2298
|
+
LC_ALL=C grep -qiE 'rate[ _]limit|secondary rate|abuse detection|already exceeded|403.*forbidden' <<<"$1"
|
|
2317
2299
|
}
|
|
2318
2300
|
|
|
2319
2301
|
# Emits the miss payload on a genuine miss and exits non-zero on anything else,
|
|
@@ -2442,7 +2424,7 @@ graphql_budget_spent() {
|
|
|
2442
2424
|
#
|
|
2443
2425
|
# NO CALLER LEARNS THE ROUTE. The answer is consumed inside this script and
|
|
2444
2426
|
# never reaches stdout, and both paths normalise to one vocabulary — see
|
|
2445
|
-
# `
|
|
2427
|
+
# `rest_pr_state`, which exists so a REST answer is indistinguishable from a
|
|
2446
2428
|
# GraphQL one.
|
|
2447
2429
|
#
|
|
2448
2430
|
# THE CHEAP PATH IS THE DEFAULT, and this function does not change that. For 93
|
|
@@ -2548,30 +2530,35 @@ gh_route() { # $1=op → graphql|rest
|
|
|
2548
2530
|
# `gh pr view 7` infers the repo from the git remote, but `gh api repos/.../pulls/7`
|
|
2549
2531
|
# has to be told. So the fallback needs one more fact than the path it replaces.
|
|
2550
2532
|
#
|
|
2551
|
-
# `--repo` may already carry it (the caller passed `-R owner/repo`)
|
|
2552
|
-
#
|
|
2553
|
-
#
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2533
|
+
# `--repo` may already carry it (the caller passed `-R owner/repo`). Otherwise
|
|
2534
|
+
# `gh api` fills `{owner}/{repo}` from the git remote, with no request. A path
|
|
2535
|
+
# naming no real repository answers 404, which `is_lookup_miss` reads as NONE.
|
|
2536
|
+
gh_rest_repo() { local d='{owner}/{repo}'; echo "${repo_args[1]:-$d}"; }
|
|
2537
|
+
|
|
2538
|
+
# ONE REST ANSWER IN GRAPHQL'S VOCABULARY: `pulls/{n}` for the PR, `check-runs` and
|
|
2539
|
+
# `status` for the rollup, folded through the SAME `PR_STATE_OF` the GraphQL arm
|
|
2540
|
+
# prints. `mergeCommit` is set for a merged PR only, because REST fills
|
|
2541
|
+
# `merge_commit_sha` with a test-merge sha on an open one. A rollup page that
|
|
2542
|
+
# holds fewer rows than `total_count` adds one QUEUED row, so a missing row can
|
|
2543
|
+
# make the answer `pending` and never `green`. Exit 1: the PR read failed (a 404
|
|
2544
|
+
# is a miss); exit 2: a later read failed, which is never a miss.
|
|
2545
|
+
rest_pr_state() { # $1=owner/repo $2=PR number or branch; returns 3 when the branch has no PR
|
|
2546
|
+
local pr sha ck='{}' st='{}'
|
|
2547
|
+
if [[ "$2" =~ ^[0-9]+$ ]]; then pr="$(gh_api_harvest "repos/$1/pulls/$2")" || return 1
|
|
2548
|
+
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
|
+
sha="$(jq -r '.head.sha // ""' <<<"$pr")"
|
|
2550
|
+
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"
|
|
2561
2552
|
}
|
|
2562
2553
|
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
mergeCommit: (.merge_commit_sha // ""), head: (.head.ref // ""), headSha: (.head.sha // ""), base: (.base.ref // ""), checks: "unknown", mergeable: mergeable_of,
|
|
2572
|
-
mergedAt: (.merged_at // "") }
|
|
2573
|
-
'
|
|
2574
|
-
}
|
|
2554
|
+
# `owner/repo` from the `origin` URL, with no host call. An `ssh://` URL may carry
|
|
2555
|
+
# a port after the host, and an scp-style remote splits host and path at its first
|
|
2556
|
+
# colon. Prints nothing and exits 1 where the URL names no `owner/repo`.
|
|
2557
|
+
gh_origin_slug() { git config --get remote.origin.url | sed -E 's#\.git/?$##; s#^.*[:/]([^/:]+/[^/:]+)$#\1#' | grep -E '^[^/]+/[^/]+$'; }
|
|
2558
|
+
|
|
2559
|
+
# `gh` as the merger identity where a Merger app token was minted, as the
|
|
2560
|
+
# signed-in one where none was. The token goes into `GH_TOKEN` only.
|
|
2561
|
+
merger_gh() { GH_TOKEN="${merger_token:-${GH_TOKEN-}}" gh "$@"; }
|
|
2575
2562
|
|
|
2576
2563
|
# Bitbucket's --state vocabulary is not GitHub's, and this adapter used to
|
|
2577
2564
|
# translate in one direction only: every response mapper turns DECLINED into
|
|
@@ -3051,11 +3038,15 @@ read_env_var() { # $1=name $2=file → the value, or nothing
|
|
|
3051
3038
|
# checkout root only for a standard `git worktree add` checkout; where the
|
|
3052
3039
|
# command fails, prints nothing, or its parent directory does not exist, this
|
|
3053
3040
|
# falls through to "no main checkout .env" rather than inventing a path.
|
|
3041
|
+
#
|
|
3042
|
+
# An exported answer for this checkout replaces both git questions
|
|
3043
|
+
# (`plot_given_common_dir`); another repository's asks git.
|
|
3054
3044
|
plot_env_file() {
|
|
3055
3045
|
local root env_file common
|
|
3056
|
-
|
|
3046
|
+
. "$here/plot-desk-root.sh"
|
|
3047
|
+
root="$(plot_given_common_dir "$PWD" top || git rev-parse --show-toplevel 2>/dev/null)" || root="."; env_file="$root/.env"
|
|
3057
3048
|
plot_env_file_qualifies "$env_file" "$1" "$2" && { printf '%s|' "$env_file"; return 0; }
|
|
3058
|
-
common="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)" && [ -n "$common" ] || return 0
|
|
3049
|
+
common="$(plot_given_common_dir "$PWD" || git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)" && [ -n "$common" ] || return 0
|
|
3059
3050
|
env_file="$(dirname "$common")/.env"
|
|
3060
3051
|
plot_env_file_qualifies "$env_file" "$1" "$2" && printf "%s|the main checkout's " "$env_file"
|
|
3061
3052
|
}
|
|
@@ -3904,8 +3895,20 @@ bb() {
|
|
|
3904
3895
|
|
|
3905
3896
|
jen() {
|
|
3906
3897
|
host_slot_take jenkins ''
|
|
3907
|
-
|
|
3908
|
-
|
|
3898
|
+
local rc
|
|
3899
|
+
if [ -n "${PLOT_JEN_BOUND_S:-}" ]; then
|
|
3900
|
+
local pid watcher was_m
|
|
3901
|
+
case $- in *m*) was_m=yes ;; *) was_m=no ;; esac; set -m
|
|
3902
|
+
command jen "$@" & pid=$!
|
|
3903
|
+
( sleep "$PLOT_JEN_BOUND_S"; kill -TERM "-$pid" ) >/dev/null 2>&1 & watcher=$!
|
|
3904
|
+
wait "$pid"; rc=$?
|
|
3905
|
+
kill "$watcher" 2>/dev/null; wait "$watcher" 2>/dev/null
|
|
3906
|
+
[ "$was_m" = yes ] || set +m
|
|
3907
|
+
[ $rc = 143 ] && echo "jen api gave no answer within ${PLOT_JEN_BOUND_S} s" >&2
|
|
3908
|
+
else
|
|
3909
|
+
command jen "$@"
|
|
3910
|
+
rc=$?
|
|
3911
|
+
fi
|
|
3909
3912
|
host_slot_give
|
|
3910
3913
|
# Jenkins is the CI axis, a connector of its own — this repo is GitHub +
|
|
3911
3914
|
# Actions while `ekzweb` is Bitbucket + Jenkins, so a `jen` call spends
|
|
@@ -4047,46 +4050,22 @@ case "$op" in
|
|
|
4047
4050
|
# learn what was just read for free.
|
|
4048
4051
|
#
|
|
4049
4052
|
# A number and a branch name need DIFFERENT endpoints, and their
|
|
4050
|
-
# payload shapes differ too — see `
|
|
4053
|
+
# payload shapes differ too — see `rest_pr_state`, which is the one
|
|
4051
4054
|
# place that knows how to read either.
|
|
4052
4055
|
rest_repo="$(gh_rest_repo)" || exit $?
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
'{"number":0,"state":"NONE","draft":false,"url":"","mergeCommit":""}' || exit $?
|
|
4061
|
-
fi
|
|
4062
|
-
else
|
|
4063
|
-
# `?head=owner:branch` is the list form. AN EMPTY ARRAY IS AN ANSWER —
|
|
4064
|
-
# the branch has no PR — while a call that never arrived is not, which
|
|
4065
|
-
# is why the empty case is handled here and the failure goes through
|
|
4066
|
-
# `host_miss_or_fail` like every other transport error.
|
|
4067
|
-
#
|
|
4068
|
-
# `state=all`, because the default is `open` and a merged PR would
|
|
4069
|
-
# otherwise read as NONE — wrong in the reassuring direction.
|
|
4070
|
-
rest_owner="${rest_repo%%/*}"
|
|
4071
|
-
if out="$(gh_api_harvest "repos/$rest_repo/pulls?head=$rest_owner:$ref&state=all&per_page=1" 2>"$HOST_ERR")"; then
|
|
4072
|
-
rm -f "$HOST_ERR"
|
|
4073
|
-
if [ "$(jq -r 'length' <<<"$out" 2>/dev/null)" = "0" ]; then
|
|
4074
|
-
echo '{"number":0,"state":"NONE","draft":false,"url":"","mergeCommit":""}'
|
|
4075
|
-
else
|
|
4076
|
-
jq -c '.[0]' <<<"$out" | rest_pr_to_state
|
|
4077
|
-
fi
|
|
4078
|
-
else
|
|
4079
|
-
host_err
|
|
4080
|
-
host_miss_or_fail "$err" \
|
|
4081
|
-
'{"number":0,"state":"NONE","draft":false,"url":"","mergeCommit":""}' || exit $?
|
|
4082
|
-
fi
|
|
4083
|
-
fi
|
|
4056
|
+
none='{"number":0,"state":"NONE","draft":false,"url":"","mergeCommit":""}'
|
|
4057
|
+
rest_pr_state "$rest_repo" "$ref" 2>"$HOST_ERR" && rm -f "$HOST_ERR" || {
|
|
4058
|
+
rc=$?; host_err
|
|
4059
|
+
[ "$rc" -ne 3 ] || { echo "$none"; exit 0; }
|
|
4060
|
+
[ "$rc" -ne 2 ] || die3 "pr-state: the checks read failed: $err"
|
|
4061
|
+
host_miss_or_fail "$err" "$none" || exit $?
|
|
4062
|
+
}
|
|
4084
4063
|
# mergeCommit is what lets a caller ask "which release contains this?" —
|
|
4085
4064
|
# `git tag --contains <sha>` answers exactly, where dates cannot. It is ""
|
|
4086
4065
|
# for anything unmerged, which is the honest answer rather than a guess.
|
|
4087
4066
|
elif out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr view "$ref" --json number,state,isDraft,url,mergeCommit,headRefName,headRefOid,baseRefName,statusCheckRollup,mergeable,mergeStateStatus,mergedAt 2>"$HOST_ERR")"; then
|
|
4088
4067
|
rm -f "$HOST_ERR"
|
|
4089
|
-
jq -c "$CHECKS_OF$MERGEABLE_OF"
|
|
4068
|
+
jq -c "$CHECKS_OF$MERGEABLE_OF$PR_STATE_OF" <<<"$out"
|
|
4090
4069
|
else
|
|
4091
4070
|
host_err
|
|
4092
4071
|
# REFUSED FOR RATE IS NOT ANSWERED. The budget gate above could not see
|
|
@@ -4391,8 +4370,17 @@ case "$op" in
|
|
|
4391
4370
|
&& printf '%s\n%s\n%s\n' "$sha" "$st" "$cm" | node "$here/board/plot-jenkins-pr-checks.mjs" review \
|
|
4392
4371
|
|| die3 "pr-review: the read failed"
|
|
4393
4372
|
exit 0; fi
|
|
4394
|
-
|
|
4395
|
-
|
|
4373
|
+
# EVERY `plot/review` STATUS IS REPORTED WITH ITS WRITER, and nothing is
|
|
4374
|
+
# decided here: `checkedReview` judges the list against the Review app's bot
|
|
4375
|
+
# login. The pages and the PR travel through stdin, never `--argjson` (the
|
|
4376
|
+
# 128 KB argv cap on Linux).
|
|
4377
|
+
# REST ONLY: `gh pr view` is GraphQL, and its secondary limit refused three
|
|
4378
|
+
# reviews on 2026-11-08 while core stood at 4797 of 5000. Comments and
|
|
4379
|
+
# statuses are paginated, and a failed read is a failed answer, never an
|
|
4380
|
+
# empty list. The pages reach `jq` through `--slurpfile`, not `--argjson`.
|
|
4381
|
+
out="$(gh_api_harvest "repos/{owner}/{repo}/pulls/${1:?pr-review needs a PR number}")" && sha="$(jq -re '.head.sha' <<<"$out")" \
|
|
4382
|
+
&& cm="$(gh api --paginate "repos/{owner}/{repo}/issues/$1/comments?per_page=100")" && st="$(gh api --paginate "repos/{owner}/{repo}/commits/$sha/statuses?per_page=100")" \
|
|
4383
|
+
&& jq -nc --arg sha "$sha" --slurpfile cm <(printf '%s' "$cm") --slurpfile st <(printf '%s' "$st") '[$st[][] | select(.context == "plot/review")] as $s | $s[0] as $m | {sha: $sha, state: ($m.state // "absent"), description: ($m.description // ""), time: ($m.updated_at // ""), bypass: any($cm[][]; .body | startswith("review-bypass:")), statuses: [$s[] | {state, description: (.description // ""), time: (.updated_at // ""), writer: (.creator.login // "")}]}' \
|
|
4396
4384
|
|| die3 "pr-review: the read failed" ;;
|
|
4397
4385
|
|
|
4398
4386
|
pr-create)
|
|
@@ -4435,10 +4423,15 @@ case "$op" in
|
|
|
4435
4423
|
# answers 5 with its one-line notice where no key is declared: the merge
|
|
4436
4424
|
# then runs as the signed-in `gh` identity. The token goes straight into
|
|
4437
4425
|
# GH_TOKEN — never into argv, a file, or a log line.
|
|
4438
|
-
merger_repo
|
|
4426
|
+
merger_repo="$(gh_origin_slug)" || die3 "pr-merge: the origin remote names no owner/repo; nothing was merged"
|
|
4439
4427
|
merger_token=$(node "$here/plot-merger-token.mjs" "$merger_repo") || { mc=$?; [ "$mc" = 5 ] || exit "$mc"; }
|
|
4440
|
-
|
|
4441
|
-
|
|
4428
|
+
# `PUT pulls/{n}/merge` with `sha` is the head pin, and GitHub answers 409
|
|
4429
|
+
# for a head that moved. A 405 (not mergeable) is a different answer and
|
|
4430
|
+
# keeps the host's own words. The branch delete is cleanup after the merge:
|
|
4431
|
+
# its failure warns and does not undo or fail the merge.
|
|
4432
|
+
if out="$(merger_gh api -X PUT "repos/{owner}/{repo}/pulls/$num/merge" -f merge_method="$([ "$squash" = 1 ] && echo squash || echo merge)" -f sha="$pin" 2>&1)"; then
|
|
4433
|
+
[ "$delbranch" != 1 ] || merger_gh api -X DELETE "repos/{owner}/{repo}/git/refs/heads/$(merger_gh api "repos/{owner}/{repo}/pulls/$num" --jq 'select(.head.repo.full_name == .base.repo.full_name) | .head.ref' 2>/dev/null)" >/dev/null 2>&1 || echo "plot-host: pr-merge: PR #$num merged, but its branch was not deleted" >&2
|
|
4434
|
+
else [[ "$out" != *"HTTP 409"* ]] || out="--match-head: head-moved — PR #$num is no longer at $pin; nothing was merged"; echo "plot-host: pr-merge: $out" >&2; exit 1; fi
|
|
4442
4435
|
# Bitbucket's merge endpoint takes no head precondition (measured 2026-10-18,
|
|
4443
4436
|
# see plan Notes), so the pin is enforced by re-reading the head via bb_state_row
|
|
4444
4437
|
# right before merging; it matches by prefix, 7+ hex (domain's sameCommit).
|
|
@@ -4457,14 +4450,13 @@ case "$op" in
|
|
|
4457
4450
|
# the second; reaching for `gh` there would put a second host caller in the
|
|
4458
4451
|
# estate.
|
|
4459
4452
|
#
|
|
4460
|
-
# Bitbucket
|
|
4461
|
-
#
|
|
4462
|
-
#
|
|
4463
|
-
#
|
|
4464
|
-
# PR is now ready or closed*.
|
|
4453
|
+
# Bitbucket runs `bb pr edit <n> --ready` (see the caveat list at the top of
|
|
4454
|
+
# this file), so a failure here surfaces as the CLI's own message rather
|
|
4455
|
+
# than being swallowed: the caller must be able to tell *the host refused*
|
|
4456
|
+
# from *the PR is now ready or closed*.
|
|
4465
4457
|
num="${1:?$op needs a PR number}"
|
|
4466
4458
|
if [ "$op" = "pr-ready" ] && [ "$cli" = "bb" ]; then
|
|
4467
|
-
bb pr
|
|
4459
|
+
bb pr edit "$num" --ready
|
|
4468
4460
|
else
|
|
4469
4461
|
"$cli" pr "${op#pr-}" "$num"
|
|
4470
4462
|
fi
|
|
@@ -4976,7 +4968,7 @@ case "$op" in
|
|
|
4976
4968
|
fi
|
|
4977
4969
|
else
|
|
4978
4970
|
pr_list_states bitbucket "$limit" "$bb_states" \
|
|
4979
|
-
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,author:(.author.nickname // "")}' \
|
|
4971
|
+
'.[] | {number:.id,title:.title,state:(if .state=="DECLINED" then "CLOSED" else .state end),head:.source.branch.name,draft:(.draft // false),url:(.links.html.href // ""),updatedAt:(.updated_on // ""),headSha:(.source.commit.hash // ""),mergedAt:(if .state=="MERGED" then (.updated_on // "") else "" end),author:(.author.nickname // ""),base:(.destination.branch.name // "")}' \
|
|
4980
4972
|
"${bb_cmd[@]}" || exit $?
|
|
4981
4973
|
fi
|
|
4982
4974
|
fi
|
|
@@ -5107,20 +5099,17 @@ case "$op" in
|
|
|
5107
5099
|
_ci="$(ci_scheme)"
|
|
5108
5100
|
case "$_ci" in
|
|
5109
5101
|
jenkins)
|
|
5110
|
-
#
|
|
5102
|
+
# `jen api` IS THE RAW PASSTHROUGH AND THE ONLY TRANSPORT. Measured
|
|
5111
5103
|
# 2026-09-10 against a live instance: a build entry from `jen build
|
|
5112
5104
|
# list --json` carries `id`, `status`, timings and stages, and a search
|
|
5113
5105
|
# of the whole payload for `sha|commit|revision|scm` matches nothing.
|
|
5114
|
-
#
|
|
5115
|
-
#
|
|
5116
|
-
#
|
|
5117
|
-
# `actions[].lastBuiltRevision.SHA1`, paired with the branch. One
|
|
5106
|
+
# Jenkins' own REST API answers it at
|
|
5107
|
+
# `actions[].lastBuiltRevision.SHA1`, paired with the branch, and
|
|
5108
|
+
# `jen api <path>` reaches it with the instance's own auth headers. One
|
|
5118
5109
|
# `tree=` query returns a whole history — 4855 bytes for five builds —
|
|
5119
5110
|
# so this costs one round trip like the GitHub arm does.
|
|
5120
5111
|
#
|
|
5121
|
-
#
|
|
5122
|
-
# the transport it had. What changed is the transport, not the rule.
|
|
5123
|
-
# The fetch, credential and match rule live in `jenkins_sha_runs`, which
|
|
5112
|
+
# THE FETCH AND MATCH RULE LIVE IN `jenkins_sha_runs`, which
|
|
5124
5113
|
# `runs-for-sha` shares. `|| exit $?` keeps exit 3 (no instance) apart
|
|
5125
5114
|
# from exit 4 (cannot be asked).
|
|
5126
5115
|
_jen_all=$(jenkins_sha_runs "$op" "$branch" "$limit" "$sha") || exit $?
|
|
@@ -5340,7 +5329,7 @@ case "$op" in
|
|
|
5340
5329
|
# `search/jql` takes the same params as v3 but returns
|
|
5341
5330
|
# `summary`/`description` as plain strings.
|
|
5342
5331
|
max="${limit:-50}"
|
|
5343
|
-
fields="summary,created,status,assignee,issuetype"
|
|
5332
|
+
fields="summary,created,status,assignee,issuetype,fixVersions"
|
|
5344
5333
|
if [ "$state" = closed ]; then
|
|
5345
5334
|
# THE CLOSED READ REQUIRES `Ticket prefixes` AND READS NOT PLOT_JIRA_JQL.
|
|
5346
5335
|
# An unscoped `resolved >=` query reads the whole instance — the hazard
|
|
@@ -5435,7 +5424,7 @@ case "$op" in
|
|
|
5435
5424
|
url: ($base + "/browse/" + .key),
|
|
5436
5425
|
createdAt: (.fields.created // ""),
|
|
5437
5426
|
status: (.fields.status.name // ""),
|
|
5438
|
-
statusCategory: (.fields.status.statusCategory.name // ""), assignees: ([.fields.assignee.emailAddress // .fields.assignee.accountId] | map(select(. != null)))
|
|
5427
|
+
statusCategory: (.fields.status.statusCategory.name // ""), assignees: ([.fields.assignee.emailAddress // .fields.assignee.accountId] | map(select(. != null))), releases: [.fields.fixVersions[]?.name]
|
|
5439
5428
|
} + (if .fields.issuetype.name then {type: .fields.issuetype.name} else {} end) + (if .fields.updated then {updatedAt: .fields.updated} else {} end) + (if ($state == "closed") or ($state == "changed" and .fields.status.statusCategory.name == "Done") then {closedAt: (.fields.resolutiondate // "")} else {} end)),
|
|
5440
5429
|
(select($paged == "1") | (.nextPageToken // empty) | {nextPageToken: .})'
|
|
5441
5430
|
elif [ "$be" = "github" ]; then
|
|
@@ -5466,7 +5455,7 @@ case "$op" in
|
|
|
5466
5455
|
# several, so a state that already uses one here is refused instead of
|
|
5467
5456
|
# silently losing the title filter (open issues is the lookup's only use).
|
|
5468
5457
|
[ -z "$title_has" ] || [ "$gh_state" = open ] || die "issue-list: --title-has only works with --state open"
|
|
5469
|
-
gh_json="number,title,url,createdAt,assignees,issueType"; search_args=(); ask_state="$gh_state"
|
|
5458
|
+
gh_json="number,title,url,createdAt,assignees,issueType,milestone"; search_args=(); ask_state="$gh_state"
|
|
5470
5459
|
[ -z "$label" ] || search_args=(--label "$label")
|
|
5471
5460
|
if [ "$gh_state" = changed ]; then gh_json+=",updatedAt,state,closedAt"; ask_state=all; search_args+=(--search "updated:>=$since")
|
|
5472
5461
|
elif [ "$gh_state" != open ]; then gh_json+=",closedAt,labels"; search_args+=(--search "closed:>=$since")
|
|
@@ -5487,7 +5476,7 @@ case "$op" in
|
|
|
5487
5476
|
jq -c --arg status "$gh_state" \
|
|
5488
5477
|
'.[] | ((.state // $status) | ascii_downcase) as $actual |
|
|
5489
5478
|
{number:.number,title:.title,url:(.url // ""),createdAt:(.createdAt // ""),
|
|
5490
|
-
status:$actual,statusCategory:(if $actual == "open" then "To Do" else "Done" end),assignees:[.assignees[]?.login]}
|
|
5479
|
+
status:$actual,statusCategory:(if $actual == "open" then "To Do" else "Done" end),assignees:[.assignees[]?.login],releases:[.milestone.title? // empty]}
|
|
5491
5480
|
+ (if .updatedAt then {updatedAt:.updatedAt} else {} end) + (if .issueType.name? then {type:.issueType.name} else {} end)
|
|
5492
5481
|
+ (if $actual == "closed" then {closedAt:(.closedAt // "")} else {} end) + (if .labels then {labels:[.labels[].name]} else {} end)' <<<"$out"
|
|
5493
5482
|
else
|
|
@@ -5746,7 +5735,7 @@ case "$op" in
|
|
|
5746
5735
|
# comment per issue and closes the issue at release; nothing reads any back,
|
|
5747
5736
|
# except `issue-comment-read`, the plan-state comment's one sanctioned
|
|
5748
5737
|
# read-back (D6: recovering ticket lines a write has no record to redo).
|
|
5749
|
-
# issue-label <n> <add> [<remove,...>] adds one label, creating it first where the repo lacks it, and removes only the listed ones the issue carries,
|
|
5738
|
+
# issue-label <n> <add> [<remove,...>] adds one label, creating it first where the repo lacks it, and removes only the listed ones the issue carries, all through REST
|
|
5750
5739
|
# issue-comment <n> <marker> <body> edits the comment holding <marker>, else posts; an empty <marker> always posts
|
|
5751
5740
|
# issue-comment-read <n> <marker> prints the marked comment's body, or nothing where none carries it
|
|
5752
5741
|
# issue-close <n>
|
|
@@ -5755,7 +5744,10 @@ case "$op" in
|
|
|
5755
5744
|
num="${1:?$op needs an issue number}"; source_said="$(issue_source)" || exit 1
|
|
5756
5745
|
[ "$be" = github ] && { [ "$source_said" = git-host ] || [ "$source_said" = $'tracker\tgithub-issues' ]; } || { echo "plot-host: $op: ${source_said#*$'\t'}" >&2; exit 4; }
|
|
5757
5746
|
case "$op" in
|
|
5758
|
-
issue-label) add="${2:?issue-label needs a label}"; carried="$(gh
|
|
5747
|
+
issue-label) add="${2:?issue-label needs a label}"; carried="$(gh api --paginate "repos/{owner}/{repo}/issues/$num/labels" -q '.[].name' 2>"$HOST_ERR")" || gh_fail
|
|
5748
|
+
gh api -X POST "repos/{owner}/{repo}/labels" -f name="$add" -f color=ededed -f description="Plot plan phase: ${add#plan:}" >"$HOST_ERR" 2>&1 || grep -q already_exists "$HOST_ERR" || gh_fail
|
|
5749
|
+
gh api -X POST "repos/{owner}/{repo}/issues/$num/labels" -f "labels[]=$add" >/dev/null 2>"$HOST_ERR" || gh_fail
|
|
5750
|
+
while IFS= read -r l; do [ -z "$l" ] || gh api -X DELETE "repos/{owner}/{repo}/issues/$num/labels/$(jq -rn --arg s "$l" '$s|@uri')" >/dev/null 2>"$HOST_ERR" || gh_fail; done < <(comm -12 <(printf '%s\n' "${3-}" | tr , '\n' | sort) <(printf '%s\n' "$carried" | sort)) ;;
|
|
5759
5751
|
issue-close) gh issue close "$num" >/dev/null 2>"$HOST_ERR" || gh_fail ;;
|
|
5760
5752
|
issue-comment)
|
|
5761
5753
|
cid="${2:+$(gh_marker_comment_id "$num" "$2")}" || gh_fail
|
|
@@ -6055,7 +6047,7 @@ case "$op" in
|
|
|
6055
6047
|
# the path, so a numeric workspace survives. An empty slug is `unsupported`.
|
|
6056
6048
|
[ "$be" = "github" ] || { node "$here/plot-bitbucket-commit-status.mjs" "$(node "$here/board/plot-bitbucket-slug.mjs" "$(git config --get remote.origin.url 2>/dev/null)")" "$@" || exit $?; exit 0; }
|
|
6057
6049
|
node "$here/plot-commit-status.mjs" --check "$@" || exit $?
|
|
6058
|
-
node "$here/plot-commit-status.mjs" --repo "$(
|
|
6050
|
+
node "$here/plot-commit-status.mjs" --repo "$(gh_origin_slug || echo GH_REPO_VIEW_FAILED)" "$@" || exit $?
|
|
6059
6051
|
;;
|
|
6060
6052
|
|
|
6061
6053
|
pr-comment)
|