@plot-pm/board 0.23.0 → 0.24.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 +251 -243
- package/package.json +3 -3
- package/plot-fleet-scan.sh +25 -5152
- package/plot-host.sh +108 -98
- package/plot-monitor-subject.sh +3 -3
- package/plot-plan-meta.sh +70 -5
package/plot-host.sh
CHANGED
|
@@ -111,22 +111,28 @@
|
|
|
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","bypass"}`:
|
|
115
|
-
# head sha, the newest `plot/review`
|
|
116
|
-
# (`success|failure|pending|error`,
|
|
117
|
-
#
|
|
118
|
-
#
|
|
114
|
+
# pr-review <number> one JSON line `{"sha","state","description","time","bypass"}`:
|
|
115
|
+
# the PR's head sha, the newest `plot/review`
|
|
116
|
+
# status on it (`success|failure|pending|error`,
|
|
117
|
+
# or `absent`), that status's description and
|
|
118
|
+
# time (both `""` where state is `absent`), and
|
|
119
|
+
# whether a comment starts `review-bypass:`.
|
|
120
|
+
# Bitbucket reads the same state words from the
|
|
119
121
|
# `plot/review` commit status (SUCCESSFUL,
|
|
120
|
-
# FAILED, INPROGRESS, STOPPED)
|
|
121
|
-
#
|
|
122
|
+
# FAILED, INPROGRESS, STOPPED), its
|
|
123
|
+
# `description`, and its `updated_on` as the
|
|
124
|
+
# time — `commit-status` writes that status
|
|
125
|
+
# through `plot-bitbucket-commit-status.mjs`.
|
|
126
|
+
# EXIT 3 is the question failing.
|
|
122
127
|
# pr-create --title T [--body B] [--base BR] [--head BR] [--draft]
|
|
123
128
|
# create a PR, print its URL
|
|
124
129
|
# pr-merge <number> [--squash] [--delete-branch] --match-head <sha>
|
|
130
|
+
# merge the PR. --match-head is
|
|
125
131
|
# mandatory on every backend. bitbucket
|
|
126
132
|
# re-reads the head before merging; a
|
|
127
133
|
# mismatch refuses `head-moved` (exit 1).
|
|
128
134
|
# pr-ready <number> take a PR out of draft
|
|
129
|
-
#
|
|
135
|
+
# pr-close <number> close a PR unmerged (bitbucket: decline)
|
|
130
136
|
# pr-list [--state open|merged|closed|all|settled] [--limit N] [--rich|--rich-open]
|
|
131
137
|
# settled is merged+declined on bitbucket (no
|
|
132
138
|
# open sweep) and --state all on github, which
|
|
@@ -470,6 +476,9 @@
|
|
|
470
476
|
# issue-comment <number> <marker> <body> (github)
|
|
471
477
|
# edits the comment holding <marker>, else posts
|
|
472
478
|
# one; an empty <marker> always posts, not idempotent.
|
|
479
|
+
# issue-comment-read <number> <marker> (github) prints the body of
|
|
480
|
+
# the comment holding <marker>, or nothing where
|
|
481
|
+
# none does. The plan-state write's one read-back.
|
|
473
482
|
# issue-list --label <label> keeps open issues carrying the label (github
|
|
474
483
|
# only; exit 4 on Bitbucket and on Jira).
|
|
475
484
|
# issue-list --title-has <text> keeps open issues whose title contains <text>,
|
|
@@ -652,10 +661,15 @@ ISSUE_PAGE_ROWS=100
|
|
|
652
661
|
# that failed, as opposed to exit 4 (cannot be asked) or an answered empty list.
|
|
653
662
|
# An empty message or a recognised lookup miss is an answer; anything else exits 3.
|
|
654
663
|
miss_or_exit3() { [ -z "$1" ] || is_lookup_miss "$1" || die3 "$1"; }
|
|
655
|
-
# `pr-merged`'s own third value for a failed call: a lookup miss
|
|
656
|
-
# not-merged
|
|
657
|
-
#
|
|
658
|
-
|
|
664
|
+
# `pr-merged`'s own third value for a failed call: a genuine PR-lookup miss
|
|
665
|
+
# still means not-merged — matched here on the same two phrases
|
|
666
|
+
# `is_lookup_miss` uses, minus its bare "not found" alternative, which also
|
|
667
|
+
# matches a failure naming no PR ("repository not found", 404) and would read
|
|
668
|
+
# as permission to delete the branch. Empty stderr is not a miss either: it
|
|
669
|
+
# is the host failing to say anything at all. Anything else answers `unknown`
|
|
670
|
+
# and prints the host's words when there are any, rather than exiting — the
|
|
671
|
+
# caller already branches on this word, not a code.
|
|
672
|
+
miss_or_unknown() { if [ -n "$1" ] && LC_ALL=C grep -qiE 'no (pull request|pullrequest)s? (found|match)|could not find.*pull request' <<<"$1"; then echo "not-merged"; else echo "${1:+plot-host: $1}" >&2; echo "unknown"; fi; }
|
|
659
673
|
gh_fail() { echo "plot-host: $(cat "$HOST_ERR" 2>/dev/null)" >&2; rm -f "$HOST_ERR"; exit 3; }
|
|
660
674
|
# Reads the last host call's stderr into `err` and removes the file, so the
|
|
661
675
|
# next call starts empty. Every failed-call branch below starts with it.
|
|
@@ -663,27 +677,20 @@ host_err() { err="$(cat "$HOST_ERR" 2>/dev/null)"; rm -f "$HOST_ERR"; }
|
|
|
663
677
|
|
|
664
678
|
# THE ONE MARKER LOOKUP, shared by `pr-comment` and `issue-comment` — GitHub's
|
|
665
679
|
# REST comments endpoint is `issues/$num/comments` for both, since a PR is an
|
|
666
|
-
# issue under the hood. Prints the id of the comment holding `$2` (a
|
|
667
|
-
# substring),
|
|
668
|
-
#
|
|
669
|
-
#
|
|
670
|
-
# never mistaken for this script's own prior post. Prints empty on no match.
|
|
671
|
-
#
|
|
672
|
-
# SCOPED TO THE LOGIN `gh api user` ANSWERS for the token this call writes
|
|
673
|
-
# with (`host.ts:358`), asked once per lookup. Not `budget_account`: it reads
|
|
674
|
-
# `hosts.yml` or `PLOT_BUDGET_ACCOUNT`, and neither names the author when
|
|
675
|
-
# `GH_TOKEN` is set or the account is a grouping name, so every lookup missed
|
|
676
|
-
# and posted a new comment.
|
|
677
|
-
#
|
|
678
|
-
# NO LOGIN, NO SCOPE. When `gh api user` fails or answers no valid login (an
|
|
679
|
-
# App installation token gets 403 there), the match falls back to the marker
|
|
680
|
-
# alone, as it was before #2661. A comment with no `user` field cannot be
|
|
681
|
-
# attributed and also matches on the marker alone.
|
|
680
|
+
# issue under the hood. Prints the id of the oldest comment holding `$2` (a
|
|
681
|
+
# substring), whatever its author, or nothing. The marker alone decides: a
|
|
682
|
+
# lookup scoped to the writer's login posted a second comment whenever another
|
|
683
|
+
# account (a person's machine, fleetd's token) wrote the same marked comment.
|
|
682
684
|
#
|
|
683
685
|
# A FAILED LISTING EXITS 3 THROUGH `gh_fail`, same as a failed edit. `set -o
|
|
684
686
|
# pipefail` (above) makes the pipeline's exit code `gh api`'s own, so a lookup
|
|
685
687
|
# that cannot be read never falls through to "no marker found, post new".
|
|
686
|
-
gh_marker_comment_id() { gh api --paginate "repos/{owner}/{repo}/issues/$1/comments" 2>"$HOST_ERR" | jq -rs --arg m "$2"
|
|
688
|
+
gh_marker_comment_id() { gh api --paginate "repos/{owner}/{repo}/issues/$1/comments" 2>"$HOST_ERR" | jq -rs --arg m "$2" '[.[][] | select(.body | contains($m))][0].id // empty'; }
|
|
689
|
+
|
|
690
|
+
# EDITS THE COMMENT `$1` HOLDS, OR POSTS `$4` TO `$3` ON `$2` (`issue` or
|
|
691
|
+
# `pr`) — shared by `issue-comment` and `pr-comment`, whose tails differed
|
|
692
|
+
# 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 "$2" comment "$3" --body "$4" >/dev/null 2>"$HOST_ERR"; fi; }
|
|
687
694
|
|
|
688
695
|
# Exit 3 — reserved for "the op itself cannot proceed", distinct from `die`'s
|
|
689
696
|
# generic 1. A Jenkins overlay with no instance to ask is such a case: a config
|
|
@@ -698,8 +705,8 @@ CHECKS_OF='def ck: (.conclusion // "") as $k | (.status // "") as $s | (if $s !=
|
|
|
698
705
|
if $k != "" and ($s|IN("","COMPLETED")) then (if ($k|IN("SUCCESS","NEUTRAL","SKIPPED")) then "ok" else "bad" end)
|
|
699
706
|
elif ($w|IN("","QUEUED","IN_PROGRESS","WAITING","REQUESTED","PENDING","EXPECTED")) then "wait"
|
|
700
707
|
elif $s == "" and $w == "SUCCESS" then "ok" else "bad" end;
|
|
701
|
-
def
|
|
702
|
-
|
|
708
|
+
def colour_of($r): if ($r|length) == 0 then "none" elif any($r[]; ck == "bad") then "failing" elif any($r[]; ck == "wait") then "pending" else "green" end;
|
|
709
|
+
def checks_of: colour_of(.statusCheckRollup // []); def ci_checks_of: colour_of([.statusCheckRollup[]? | select((.context // .name // "") != "plot/review")]);'
|
|
703
710
|
|
|
704
711
|
# THE ONE FOLD of a PR's mergeability into a word, for `pr-list --rich` and both
|
|
705
712
|
# `pr-state` transports. GraphQL says `mergeable` CONFLICTING|MERGEABLE|UNKNOWN
|
|
@@ -852,15 +859,11 @@ pr_list_failed() { # $1=stderr text
|
|
|
852
859
|
# NO REPAIR NAMED, AND THAT IS THE ANSWER. A burst refusal clears in
|
|
853
860
|
# seconds and nothing is broken, so `$cli auth login` here would send a
|
|
854
861
|
# reader to fix a login that is already fine. The decision is the wait.
|
|
855
|
-
|
|
856
|
-
echo " Nothing is wrong and nothing needs fixing: this limit bounds calls at" >&2
|
|
857
|
-
echo " once, not per hour. Retry shortly, with fewer at a time." >&2
|
|
862
|
+
printf '%s\n' "plot-host: pr-list: host refused a burst — ${err:-the host refused the request and said nothing}" " Nothing is wrong and nothing needs fixing: this limit bounds calls at" " once, not per hour. Retry shortly, with fewer at a time." >&2
|
|
858
863
|
exit 6
|
|
859
864
|
;;
|
|
860
865
|
throttled)
|
|
861
|
-
|
|
862
|
-
echo " The window's quota is spent. Wait for the reset the message names," >&2
|
|
863
|
-
echo " or run against an account with quota left. No login will help." >&2
|
|
866
|
+
printf '%s\n' "plot-host: pr-list: host throttled — ${err:-the host refused the request and said nothing}" " The window's quota is spent. Wait for the reset the message names," " or run against an account with quota left. No login will help." >&2
|
|
864
867
|
exit 5
|
|
865
868
|
;;
|
|
866
869
|
timeout)
|
|
@@ -868,9 +871,7 @@ pr_list_failed() { # $1=stderr text
|
|
|
868
871
|
# 504 means the server took too long, not that the credential is bad, so
|
|
869
872
|
# `host_repair`'s `gh auth login` would send a reader to fix a login
|
|
870
873
|
# that was never broken. The decision is to ask again, not to log in.
|
|
871
|
-
|
|
872
|
-
echo " Nothing is wrong with the login: the server took too long to answer." >&2
|
|
873
|
-
echo " The next refresh asks again." >&2
|
|
874
|
+
printf '%s\n' "plot-host: pr-list: host timed out — ${err:-the host took too long and said nothing}" " Nothing is wrong with the login: the server took too long to answer." " The next refresh asks again." >&2
|
|
874
875
|
exit 3
|
|
875
876
|
;;
|
|
876
877
|
esac
|
|
@@ -1388,6 +1389,7 @@ bb_window_listing() { # global bb args… --state <s> --json → one JSON array
|
|
|
1388
1389
|
echo "bitbucket window state=$_st is short ($_got of $_size matches after $_pages pages); refusing it rather than printing it as whole" >&2
|
|
1389
1390
|
return 3
|
|
1390
1391
|
fi
|
|
1392
|
+
echo "plot-host: bitbucket pr-list state=$_st window complete ($_got matches, every page read) — this window holds every pull request the host has in this state since the stamp" >&2
|
|
1391
1393
|
printf '%s' "$_rows"
|
|
1392
1394
|
}
|
|
1393
1395
|
|
|
@@ -1891,10 +1893,7 @@ jenkins_instance() {
|
|
|
1891
1893
|
# only a person can fix, and deliberately NOT exit 4: a `CI: jenkins` repository
|
|
1892
1894
|
# CAN be asked about builds, it just has not said where.
|
|
1893
1895
|
jenkins_no_instance() {
|
|
1894
|
-
|
|
1895
|
-
echo " Add a 'Jenkins instance' key to the ## Plot Config section of CLAUDE.md," >&2
|
|
1896
|
-
echo " naming the instance \`jen\` knows, or set JENKINS_INSTANCE." >&2
|
|
1897
|
-
echo " Or drop the 'CI: jenkins' key to read build status from the git host." >&2
|
|
1896
|
+
printf '%s\n' "plot-host: CI is jenkins but no Jenkins instance is configured" " Add a 'Jenkins instance' key to the ## Plot Config section of CLAUDE.md," " naming the instance \`jen\` knows, or set JENKINS_INSTANCE." " Or drop the 'CI: jenkins' key to read build status from the git host." >&2
|
|
1898
1897
|
exit 3
|
|
1899
1898
|
}
|
|
1900
1899
|
|
|
@@ -1953,7 +1952,7 @@ jenkins_job_url_path() { # $1 = job path, $2 = branch or ""
|
|
|
1953
1952
|
# names no parenthesized host. The caller decides what an unresolved host
|
|
1954
1953
|
# means, same contract as every other helper here.
|
|
1955
1954
|
jenkins_resolve_host() {
|
|
1956
|
-
local line; line=$(jen -I "$1" auth status 2>&1 | grep -iE '^Instance:' | head -1)
|
|
1955
|
+
local line; line=$(jen -I "$1" auth status 2>&1 | grep -iE '^Instance:' | head -1)
|
|
1957
1956
|
[ -n "$line" ] || return 1
|
|
1958
1957
|
sed -nE 's/.*\(https?:\/\/([^)\/]+).*/\1/p' <<<"$line" | grep . || return 2
|
|
1959
1958
|
}
|
|
@@ -2240,13 +2239,9 @@ bb_state_row() {
|
|
|
2240
2239
|
ci_unaskable() { # $1 = the op's name, $2 = the CI word (may be empty)
|
|
2241
2240
|
local ci_word="${2:-}"
|
|
2242
2241
|
if [ -z "$ci_word" ] || [ "$ci_word" = none ]; then
|
|
2243
|
-
|
|
2244
|
-
echo " Add a 'CI' key to the ## Plot Config section of CLAUDE.md naming the" >&2
|
|
2245
|
-
echo " system that builds this repository — \`github-actions\` or \`jenkins\`." >&2
|
|
2242
|
+
printf '%s\n' "plot-host: $1 — this repository declares no CI system, so there is nothing to ask" " Add a 'CI' key to the ## Plot Config section of CLAUDE.md naming the" " system that builds this repository — \`github-actions\` or \`jenkins\`." >&2
|
|
2246
2243
|
else
|
|
2247
|
-
|
|
2248
|
-
echo " Plot answers this op for \`github-actions\` and \`jenkins\`. An unknown" >&2
|
|
2249
|
-
echo " system cannot be asked, which is not the same as having no runs." >&2
|
|
2244
|
+
printf '%s\n' "plot-host: $1 — no connector for CI system '$ci_word'" " Plot answers this op for \`github-actions\` and \`jenkins\`. An unknown" " system cannot be asked, which is not the same as having no runs." >&2
|
|
2250
2245
|
fi
|
|
2251
2246
|
exit 4
|
|
2252
2247
|
}
|
|
@@ -2573,7 +2568,7 @@ rest_pr_to_state() {
|
|
|
2573
2568
|
state: $state,
|
|
2574
2569
|
draft: (.draft // false),
|
|
2575
2570
|
url: (.html_url // ""),
|
|
2576
|
-
mergeCommit: (.merge_commit_sha // ""), headSha: (.head.sha // ""), base: (.base.ref // ""), checks: "unknown", mergeable: mergeable_of,
|
|
2571
|
+
mergeCommit: (.merge_commit_sha // ""), head: (.head.ref // ""), headSha: (.head.sha // ""), base: (.base.ref // ""), checks: "unknown", mergeable: mergeable_of,
|
|
2577
2572
|
mergedAt: (.merged_at // "") }
|
|
2578
2573
|
'
|
|
2579
2574
|
}
|
|
@@ -3103,10 +3098,7 @@ jira_require_config() {
|
|
|
3103
3098
|
[ -n "$(tracker_base_url)" ] || die3 "Tracker is jira but no base URL is configured (write 'Tracker: jira https://your.atlassian.net' or set PLOT_JIRA_BASE_URL)"
|
|
3104
3099
|
jira_load_env_file
|
|
3105
3100
|
if [ -z "${JIRA_EMAIL:-}" ] || [ -z "${JIRA_API_TOKEN:-}" ]; then
|
|
3106
|
-
|
|
3107
|
-
echo " Create a token at https://id.atlassian.com/manage-profile/security/api-tokens" >&2
|
|
3108
|
-
echo " then export JIRA_EMAIL=<your account email> and JIRA_API_TOKEN=<the token>," >&2
|
|
3109
|
-
echo " or put both in this repository's .env (which .gitignore already excludes)." >&2
|
|
3101
|
+
printf '%s\n' "plot-host: Jira needs JIRA_EMAIL and JIRA_API_TOKEN in the environment — an unauthenticated Jira must not read as an empty inbox" " Create a token at https://id.atlassian.com/manage-profile/security/api-tokens" " then export JIRA_EMAIL=<your account email> and JIRA_API_TOKEN=<the token>," " or put both in this repository's .env (which .gitignore already excludes)." >&2
|
|
3110
3102
|
exit 3
|
|
3111
3103
|
fi
|
|
3112
3104
|
}
|
|
@@ -3952,6 +3944,8 @@ be="$(backend)" || exit $?
|
|
|
3952
3944
|
# emptiness is the honest value — there is no route where there is no fork.
|
|
3953
3945
|
route=""
|
|
3954
3946
|
[ "$be" = "github" ] && route="$(gh_route "$op")"
|
|
3947
|
+
# THE HOST CLI FOR OPS WHOSE TWO ARMS DIFFER ONLY IN ITS NAME.
|
|
3948
|
+
cli=gh; [ "$be" = "github" ] || cli=bb
|
|
3955
3949
|
|
|
3956
3950
|
case "$op" in
|
|
3957
3951
|
backend)
|
|
@@ -4090,9 +4084,9 @@ case "$op" in
|
|
|
4090
4084
|
# mergeCommit is what lets a caller ask "which release contains this?" —
|
|
4091
4085
|
# `git tag --contains <sha>` answers exactly, where dates cannot. It is ""
|
|
4092
4086
|
# for anything unmerged, which is the honest answer rather than a guess.
|
|
4093
|
-
elif out="$(gh ${repo_args[@]+"${repo_args[@]}"} pr view "$ref" --json number,state,isDraft,url,mergeCommit,headRefOid,baseRefName,statusCheckRollup,mergeable,mergeStateStatus,mergedAt 2>"$HOST_ERR")"; then
|
|
4087
|
+
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
|
|
4094
4088
|
rm -f "$HOST_ERR"
|
|
4095
|
-
jq -c "$CHECKS_OF$MERGEABLE_OF"'{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),headSha:(.headRefOid // ""),base:(.baseRefName // ""),checks:checks_of,checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}' <<<"$out"
|
|
4089
|
+
jq -c "$CHECKS_OF$MERGEABLE_OF"'{number:.number,state:.state,draft:.isDraft,url:.url,mergeCommit:(.mergeCommit.oid // ""),head:(.headRefName // ""),headSha:(.headRefOid // ""),base:(.baseRefName // ""),checks:checks_of,checksSha:(.headRefOid // ""),mergeable:mergeable_of,mergedAt:(.mergedAt // "")}' <<<"$out"
|
|
4096
4090
|
else
|
|
4097
4091
|
host_err
|
|
4098
4092
|
# REFUSED FOR RATE IS NOT ANSWERED. The budget gate above could not see
|
|
@@ -4398,7 +4392,7 @@ case "$op" in
|
|
|
4398
4392
|
|| die3 "pr-review: the read failed"
|
|
4399
4393
|
exit 0; fi
|
|
4400
4394
|
out="$(gh pr view "${1:?pr-review needs a PR number}" --json headRefOid,comments)" && st="$(gh api "repos/{owner}/{repo}/commits/$(jq -r .headRefOid <<<"$out")/statuses")" \
|
|
4401
|
-
&& jq -c --argjson st "$st" '
|
|
4395
|
+
&& jq -c --argjson st "$st" '[$st[] | select(.context == "plot/review")][0] as $m | {sha: .headRefOid, state: ($m.state // "absent"), description: ($m.description // ""), time: ($m.updated_at // ""), bypass: any(.comments[]?; .body | startswith("review-bypass:"))}' <<<"$out" \
|
|
4402
4396
|
|| die3 "pr-review: the read failed" ;;
|
|
4403
4397
|
|
|
4404
4398
|
pr-create)
|
|
@@ -4455,21 +4449,24 @@ case "$op" in
|
|
|
4455
4449
|
fi
|
|
4456
4450
|
;;
|
|
4457
4451
|
|
|
4458
|
-
pr-ready)
|
|
4459
|
-
# TAKE A PR OUT OF DRAFT
|
|
4460
|
-
#
|
|
4461
|
-
#
|
|
4452
|
+
pr-ready|pr-close)
|
|
4453
|
+
# TAKE A PR OUT OF DRAFT (`pr-ready`) OR CLOSE IT WITHOUT MERGING (`pr-close`;
|
|
4454
|
+
# `bb pr close` declines). One call each, and the ONE place that talks to the
|
|
4455
|
+
# host CLI keeps that property — `plot-approve.sh` needs the first before it
|
|
4456
|
+
# merges, and the repair arm closes the fix and revert PRs of an episode with
|
|
4457
|
+
# the second; reaching for `gh` there would put a second host caller in the
|
|
4458
|
+
# estate.
|
|
4462
4459
|
#
|
|
4463
4460
|
# Bitbucket's support depends on the bb CLI version (see the caveat list at
|
|
4464
4461
|
# the top of this file, which already names `--draft`/`--ready`), so a
|
|
4465
4462
|
# failure here surfaces as the CLI's own message rather than being
|
|
4466
4463
|
# swallowed: the caller must be able to tell *the host refused* from *the
|
|
4467
|
-
# PR is now ready*.
|
|
4468
|
-
num="${1
|
|
4469
|
-
if [ "$
|
|
4470
|
-
gh pr ready "$num"
|
|
4471
|
-
else
|
|
4464
|
+
# PR is now ready or closed*.
|
|
4465
|
+
num="${1:?$op needs a PR number}"
|
|
4466
|
+
if [ "$op" = "pr-ready" ] && [ "$cli" = "bb" ]; then
|
|
4472
4467
|
bb pr update "$num" --ready
|
|
4468
|
+
else
|
|
4469
|
+
"$cli" pr "${op#pr-}" "$num"
|
|
4473
4470
|
fi
|
|
4474
4471
|
;;
|
|
4475
4472
|
|
|
@@ -4796,15 +4793,14 @@ case "$op" in
|
|
|
4796
4793
|
| jq -c "$CHECKS_OF$MERGEABLE_OF"'.[] | {
|
|
4797
4794
|
number:.number, title:.title, state:.state, head:.headRefName,
|
|
4798
4795
|
draft:.isDraft,
|
|
4799
|
-
checks:checks_of,
|
|
4800
|
-
mergeable:mergeable_of,
|
|
4796
|
+
checks:checks_of, mergeable:mergeable_of,
|
|
4801
4797
|
review:(.reviewDecision // ""),
|
|
4802
4798
|
url:.url,
|
|
4803
4799
|
updatedAt:(.updatedAt // ""),headSha:(.headRefOid // ""),checksSha:(.headRefOid // ""),mergedAt:(.mergedAt // ""),
|
|
4804
4800
|
author:(.author.login // ""),
|
|
4805
4801
|
failing_checks:[
|
|
4806
|
-
.statusCheckRollup[]? | select(ck == "bad") | (.name // .context // "")] | map(select(. != ""))
|
|
4807
|
-
}'
|
|
4802
|
+
.statusCheckRollup[]? | select(ck == "bad") | (.name // .context // "")] | map(select(. != "")), ciChecks:ci_checks_of
|
|
4803
|
+
} + (([.statusCheckRollup[]? | select((.context // "") == "plot/review")] | .[0]) as $pr | if $pr == null then {plotReview:"absent"} else {plotReview:($pr.state // "" | ascii_downcase), plotReviewSha:(.headRefOid // ""), plotReviewAt:($pr.startedAt // "")} end)'
|
|
4808
4804
|
fi
|
|
4809
4805
|
else
|
|
4810
4806
|
# `isDraft`, `url` AND `updatedAt` TRAVEL ON THE PLAIN ARM TOO, and they
|
|
@@ -5028,9 +5024,7 @@ case "$op" in
|
|
|
5028
5024
|
# `CI: github-actions` on a Bitbucket remote has declared something
|
|
5029
5025
|
# `gh` cannot reach — an unaskable configuration, not an empty history.
|
|
5030
5026
|
if [ "$be" != "github" ]; then
|
|
5031
|
-
|
|
5032
|
-
echo " \`gh run list\` reads the runs of the repository its remote names," >&2
|
|
5033
|
-
echo " so there is no GitHub repository here to ask about." >&2
|
|
5027
|
+
printf '%s\n' "plot-host: runs — CI is github-actions but the git host is '$be'" " \`gh run list\` reads the runs of the repository its remote names," " so there is no GitHub repository here to ask about." >&2
|
|
5034
5028
|
exit 4
|
|
5035
5029
|
fi
|
|
5036
5030
|
gh run list --branch "$branch" --limit "$limit" \
|
|
@@ -5145,9 +5139,7 @@ case "$op" in
|
|
|
5145
5139
|
# SAME SECOND CONDITION AS `runs`: `gh run list` reads the repository its
|
|
5146
5140
|
# remote names, so `CI: github-actions` on a non-GitHub remote names runs
|
|
5147
5141
|
# that cannot be reached from here.
|
|
5148
|
-
|
|
5149
|
-
echo " \`gh run list\` reads the runs of the repository its remote names," >&2
|
|
5150
|
-
echo " so there is no GitHub repository here to ask about." >&2
|
|
5142
|
+
printf '%s\n' "plot-host: $op — CI is github-actions but the git host is '$be'" " \`gh run list\` reads the runs of the repository its remote names," " so there is no GitHub repository here to ask about." >&2
|
|
5151
5143
|
exit 4
|
|
5152
5144
|
fi
|
|
5153
5145
|
# From here the CI system is `github-actions` and the git host is GitHub;
|
|
@@ -5201,6 +5193,23 @@ case "$op" in
|
|
|
5201
5193
|
'$match[0] + {jobs: [$run[0].jobs[] | {conclusion, startedAt, completedAt, steps: [(.steps // [])[].conclusion]}]}' || exit 4
|
|
5202
5194
|
;;
|
|
5203
5195
|
|
|
5196
|
+
rerun-failed|rerun-all)
|
|
5197
|
+
# `rerun-failed` re-runs the failed jobs of every concluded-red run for ONE
|
|
5198
|
+
# sha; `rerun-all` re-runs every job of every run for it, whatever each
|
|
5199
|
+
# concluded. GitHub resets a re-run run's `startedAt` to the new attempt.
|
|
5200
|
+
# Exit 4 is *cannot be asked*: any CI but GitHub Actions on GitHub, and a
|
|
5201
|
+
# failing `gh`. Exit 1 is `rerun-all` matching no run for the sha: nothing
|
|
5202
|
+
# was re-run, so a caller waiting for a new attempt would wait forever.
|
|
5203
|
+
branch="${1:?$op needs a branch}"; sha="${2:?$op needs a sha}"
|
|
5204
|
+
[ "$(ci_scheme)" = github-actions ] && [ "$be" = github ] || exit 4
|
|
5205
|
+
# Empty for `rerun-all`; non-empty, and so `--failed` below, for `rerun-failed`.
|
|
5206
|
+
_failed_only=${op#rerun-all}
|
|
5207
|
+
_ids=$(gh run list --branch "$branch" --limit 50 --json headSha,conclusion,databaseId \
|
|
5208
|
+
--jq ".[] | select(.headSha == \"$sha\" and (\"$_failed_only\" == \"\" or .conclusion == \"failure\")) | .databaseId" 2>/dev/null) || exit 4
|
|
5209
|
+
[ -n "$_ids$_failed_only" ] || exit 1
|
|
5210
|
+
for _id in $_ids; do gh run rerun "$_id" ${_failed_only:+--failed} >/dev/null 2>&1 || exit 4; done
|
|
5211
|
+
;;
|
|
5212
|
+
|
|
5204
5213
|
issue-list)
|
|
5205
5214
|
# Open tracker issues — the board's inbox, and READ-ONLY in both
|
|
5206
5215
|
# directions. Nothing here writes a label, an assignee or a close: the
|
|
@@ -5460,7 +5469,7 @@ case "$op" in
|
|
|
5460
5469
|
gh_json="number,title,url,createdAt,assignees,issueType"; search_args=(); ask_state="$gh_state"
|
|
5461
5470
|
[ -z "$label" ] || search_args=(--label "$label")
|
|
5462
5471
|
if [ "$gh_state" = changed ]; then gh_json+=",updatedAt,state,closedAt"; ask_state=all; search_args+=(--search "updated:>=$since")
|
|
5463
|
-
elif [ "$gh_state" != open ]; then gh_json+=",closedAt"; search_args+=(--search "closed:>=$since")
|
|
5472
|
+
elif [ "$gh_state" != open ]; then gh_json+=",closedAt,labels"; search_args+=(--search "closed:>=$since")
|
|
5464
5473
|
# TITLE SEARCH NARROWS, IT DOES NOT REPLACE THE LABEL FILTER: both are
|
|
5465
5474
|
# qualifiers `gh` combines in one `--search` string, so a backlog's
|
|
5466
5475
|
# label stays the safety net while the title cuts the read to the one PR
|
|
@@ -5480,7 +5489,7 @@ case "$op" in
|
|
|
5480
5489
|
{number:.number,title:.title,url:(.url // ""),createdAt:(.createdAt // ""),
|
|
5481
5490
|
status:$actual,statusCategory:(if $actual == "open" then "To Do" else "Done" end),assignees:[.assignees[]?.login]}
|
|
5482
5491
|
+ (if .updatedAt then {updatedAt:.updatedAt} else {} end) + (if .issueType.name? then {type:.issueType.name} else {} end)
|
|
5483
|
-
+ (if $actual == "closed" then {closedAt:(.closedAt // "")} else {} end)' <<<"$out"
|
|
5492
|
+
+ (if $actual == "closed" then {closedAt:(.closedAt // "")} else {} end) + (if .labels then {labels:[.labels[].name]} else {} end)' <<<"$out"
|
|
5484
5493
|
else
|
|
5485
5494
|
# NO empty-list fallback. `host_miss_or_fail` exists for a lookup whose
|
|
5486
5495
|
# subject is absent — one PR that does not exist. A LIST has no absent
|
|
@@ -5561,7 +5570,7 @@ case "$op" in
|
|
|
5561
5570
|
# exit codes are deliberately THE SAME ONES — a consumer that already maps
|
|
5562
5571
|
# 4 to `unsupported` and anything else to `failed` must not need a second
|
|
5563
5572
|
# table to read this op.
|
|
5564
|
-
num="${1:?issue-view needs an issue number}"
|
|
5573
|
+
num="${1:?issue-view needs an issue number}"
|
|
5565
5574
|
# Asked once, before the arms, exactly as issue-list does — the same
|
|
5566
5575
|
# question with the same three answers and the same exit codes. A consumer
|
|
5567
5576
|
# that maps 4 to `unsupported` needs no second table to read this op.
|
|
@@ -5732,12 +5741,15 @@ case "$op" in
|
|
|
5732
5741
|
*) echo "plot-host: issue-open: ${source_said#*$'\t'}" >&2; exit 4 ;;
|
|
5733
5742
|
esac ;;
|
|
5734
5743
|
|
|
5735
|
-
issue-label|issue-comment|issue-close)
|
|
5744
|
+
issue-label|issue-comment|issue-comment-read|issue-close)
|
|
5736
5745
|
# THE PLAN-STATE WRITES, and one-way: Plot sets a `plan:*` label, keeps one
|
|
5737
|
-
# comment per issue and closes the issue at release; nothing reads any back
|
|
5738
|
-
#
|
|
5739
|
-
#
|
|
5740
|
-
# issue-
|
|
5746
|
+
# comment per issue and closes the issue at release; nothing reads any back,
|
|
5747
|
+
# except `issue-comment-read`, the plan-state comment's one sanctioned
|
|
5748
|
+
# 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, in one `gh issue edit`
|
|
5750
|
+
# issue-comment <n> <marker> <body> edits the comment holding <marker>, else posts; an empty <marker> always posts
|
|
5751
|
+
# issue-comment-read <n> <marker> prints the marked comment's body, or nothing where none carries it
|
|
5752
|
+
# issue-close <n>
|
|
5741
5753
|
# GitHub issues only, dispatched on `issue_source` like issue-open. Exit 4,
|
|
5742
5754
|
# with the reason, for a source that cannot be asked.
|
|
5743
5755
|
num="${1:?$op needs an issue number}"; source_said="$(issue_source)" || exit 1
|
|
@@ -5746,9 +5758,11 @@ case "$op" in
|
|
|
5746
5758
|
issue-label) add="${2:?issue-label needs a label}"; carried="$(gh issue view "$num" --json labels -q '.labels[].name' 2>"$HOST_ERR")" || gh_fail; keep="$(comm -12 <(printf '%s\n' "${3-}" | tr , '\n' | sort) <(printf '%s\n' "$carried" | sort) | paste -sd, -)"; gh label create "$add" --color ededed --description "Plot plan phase: ${add#plan:}" >/dev/null 2>"$HOST_ERR" || grep -qi 'already exists' "$HOST_ERR" || gh_fail; gh issue edit "$num" --add-label "$add" ${keep:+--remove-label "$keep"} >/dev/null 2>"$HOST_ERR" || gh_fail ;;
|
|
5747
5759
|
issue-close) gh issue close "$num" >/dev/null 2>"$HOST_ERR" || gh_fail ;;
|
|
5748
5760
|
issue-comment)
|
|
5749
|
-
cid="
|
|
5750
|
-
|
|
5751
|
-
|
|
5761
|
+
cid="${2:+$(gh_marker_comment_id "$num" "$2")}" || gh_fail
|
|
5762
|
+
gh_edit_or_post_comment "$cid" issue "$num" "${3-}" || gh_fail ;;
|
|
5763
|
+
issue-comment-read)
|
|
5764
|
+
cid="$(gh_marker_comment_id "$num" "${2:?issue-comment-read needs a marker}")" || gh_fail
|
|
5765
|
+
[ -z "$cid" ] || gh api "repos/{owner}/{repo}/issues/comments/$cid" -q .body 2>"$HOST_ERR" || gh_fail ;;
|
|
5752
5766
|
esac
|
|
5753
5767
|
rm -f "$HOST_ERR" ;;
|
|
5754
5768
|
|
|
@@ -5771,11 +5785,7 @@ case "$op" in
|
|
|
5771
5785
|
esac
|
|
5772
5786
|
done
|
|
5773
5787
|
[ -n "$body" ] || die "pr-body needs --body"
|
|
5774
|
-
|
|
5775
|
-
gh pr edit "$num" --body "$body"
|
|
5776
|
-
else
|
|
5777
|
-
bb pr edit "$num" --body "$body"
|
|
5778
|
-
fi
|
|
5788
|
+
"$cli" pr edit "$num" --body "$body"
|
|
5779
5789
|
;;
|
|
5780
5790
|
|
|
5781
5791
|
rate-limit)
|
|
@@ -6052,11 +6062,11 @@ case "$op" in
|
|
|
6052
6062
|
# KEYED BY PR NUMBER, NOT A SHA — unlike commit-status, this writes through
|
|
6053
6063
|
# the signed-in CLI identity, so it needs no App credentials and no Node
|
|
6054
6064
|
# helper.
|
|
6055
|
-
[ "$be" = "github" ] || { echo "plot-host: pr-comment: bitbucket has no verified pr-comment write" >&2; exit 4; }; num="${1:?pr-comment needs a PR number}"
|
|
6056
|
-
|
|
6057
|
-
|
|
6065
|
+
[ "$be" = "github" ] || { echo "plot-host: pr-comment: bitbucket has no verified pr-comment write" >&2; exit 4; }; num="${1:?pr-comment needs a PR number}"
|
|
6066
|
+
cid="${3:+$(gh_marker_comment_id "$num" "$3")}" || gh_fail
|
|
6067
|
+
gh_edit_or_post_comment "$cid" pr "$num" "${2:?pr-comment needs a body}" || gh_fail; rm -f "$HOST_ERR" ;;
|
|
6058
6068
|
|
|
6059
6069
|
*)
|
|
6060
|
-
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-close|version-list|pr-body|pr-review|rate-limit|limit|ci-limit|spend-rate|commit-status|pr-comment)"
|
|
6070
|
+
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|rate-limit|limit|ci-limit|spend-rate|commit-status|pr-comment)"
|
|
6061
6071
|
;;
|
|
6062
6072
|
esac
|
package/plot-monitor-subject.sh
CHANGED
|
@@ -124,11 +124,11 @@ plot_monitor_subject() {
|
|
|
124
124
|
# PRODUCTION IS UNCHANGED: a real worktree outlives its agent, so the
|
|
125
125
|
# directory is present and this reads `starting` exactly as before.
|
|
126
126
|
if [ ! -f "$pid_file" ]; then
|
|
127
|
-
[ -d "$
|
|
127
|
+
[ -d "${pid_file%/*}" ] && { printf 'starting'; return 0; }
|
|
128
128
|
printf 'gone'; return 0
|
|
129
129
|
fi
|
|
130
130
|
|
|
131
|
-
pid
|
|
131
|
+
read -r pid < "$pid_file" 2>/dev/null
|
|
132
132
|
|
|
133
133
|
# A file that exists but holds no digits is a half-written pid, which is the
|
|
134
134
|
# startup window caught mid-`printf`. Not gone — UNLESS the wrapper has
|
|
@@ -140,7 +140,7 @@ plot_monitor_subject() {
|
|
|
140
140
|
# would read `starting` forever.
|
|
141
141
|
case "$pid" in
|
|
142
142
|
'' | *[!0-9]*)
|
|
143
|
-
if [ -f "$
|
|
143
|
+
if [ -f "${pid_file%/*}/.plot-worker.exit" ]; then
|
|
144
144
|
printf 'gone'; return 0
|
|
145
145
|
fi
|
|
146
146
|
printf 'starting'; return 0 ;;
|
package/plot-plan-meta.sh
CHANGED
|
@@ -243,6 +243,21 @@
|
|
|
243
243
|
# heading's branch is read instead (see the heading handler).
|
|
244
244
|
# `wave` is the wave NAME, not an index. ALWAYS present; []
|
|
245
245
|
# when every such item was attributed.
|
|
246
|
+
# unread_branch_items
|
|
247
|
+
# `{ wave, branch, line }` triples, in document order, for a
|
|
248
|
+
# list item in a slice section that is NOT a claim
|
|
249
|
+
# (branch_claim_re) and yet holds a token matching a
|
|
250
|
+
# configured branch prefix, inside or outside a code span —
|
|
251
|
+
# a report, not a refusal. Catches a foreign-repository
|
|
252
|
+
# branch named in prose rather than claimed, which the claim
|
|
253
|
+
# grammar never reads at all (unlike unread_heading_items,
|
|
254
|
+
# whose items are already claims the heading cannot
|
|
255
|
+
# attribute). `idea/` tokens, names holding `*`, and file
|
|
256
|
+
# paths (a `.` after the prefix) are not read as a branch. An
|
|
257
|
+
# item carrying `<!-- deferred: ... -->` is excluded: a
|
|
258
|
+
# person already accepted it has no branch yet. `wave` is the
|
|
259
|
+
# wave NAME, "" when the item precedes any heading. ALWAYS
|
|
260
|
+
# present; [] when none.
|
|
246
261
|
# issues tracker issue numbers this plan answers, from the `## Status`
|
|
247
262
|
# `Issue:` line or front matter `issue:` (sorted, unique).
|
|
248
263
|
# A DEDICATED field, never a scan of the body for `#NNN`: a
|
|
@@ -337,7 +352,7 @@ if [ ${#files[@]} -eq 0 ] && [ ${#missing[@]} -eq 0 ]; then
|
|
|
337
352
|
fi
|
|
338
353
|
|
|
339
354
|
for f in ${missing[@]+"${missing[@]}"}; do
|
|
340
|
-
printf '{"file":"%s","format":"none","error":"file not found","phase_raw":"","phase":"NONE","phase_alt_raw":"","phase_alt":"NONE","type":"","title":"","sprint":"","story":"","assignee":"","branches":[],"prs":[],"deferred_prs":[],"issues":[],"ticket":"","malformed_prs":[],"changelog":[],"long_wave_names":[],"unread_branch_headings":[],"unread_waits":[],"unread_heading_items":[],"review_raw":"","review":"NONE","impl_raw":"","impl":"NONE","design_raw":"","spike_approved_raw":"","approved_raw":"","released_raw":"","delivered_raw":"","verified_raw":"","started_raw":[]}\n' \
|
|
355
|
+
printf '{"file":"%s","format":"none","error":"file not found","phase_raw":"","phase":"NONE","phase_alt_raw":"","phase_alt":"NONE","type":"","title":"","sprint":"","story":"","assignee":"","branches":[],"prs":[],"deferred_prs":[],"issues":[],"ticket":"","malformed_prs":[],"changelog":[],"long_wave_names":[],"unread_branch_headings":[],"unread_waits":[],"unread_heading_items":[],"unread_branch_items":[],"review_raw":"","review":"NONE","impl_raw":"","impl":"NONE","design_raw":"","spike_approved_raw":"","approved_raw":"","released_raw":"","delivered_raw":"","verified_raw":"","started_raw":[]}\n' \
|
|
341
356
|
"$(printf '%s' "$f" | sed 's/\\/\\\\/g; s/"/\\"/g')"
|
|
342
357
|
done
|
|
343
358
|
|
|
@@ -384,11 +399,14 @@ function sorted_insert(arr, n, v, j) {
|
|
|
384
399
|
arr[j+1] = v
|
|
385
400
|
return n + 1
|
|
386
401
|
}
|
|
387
|
-
# Renders `n` `{"k1":"...","k2":"..."}` objects, reading
|
|
388
|
-
# i=1..n
|
|
389
|
-
|
|
402
|
+
# Renders `n` `{"k1":"...","k2":"...",["k3":"..."]}` objects, reading
|
|
403
|
+
# arr1[i]/arr2[i][/arr3[i]] for i=1..n. k3 "" omits the third field — the two-key
|
|
404
|
+
# shape unread_waits and unread_heading_items emit; unread_branch_items passes
|
|
405
|
+
# k3 for its third, "line".
|
|
406
|
+
function emit_pairs(n, k1, arr1, k2, arr2, k3, arr3, i, out) {
|
|
390
407
|
for (i = 1; i <= n; i++)
|
|
391
|
-
out = out (i > 1 ? "," : "") "{\"" k1 "\":\"" jesc(arr1[i]) "\",\"" k2 "\":\"" jesc(arr2[i]) "\"
|
|
408
|
+
out = out (i > 1 ? "," : "") "{\"" k1 "\":\"" jesc(arr1[i]) "\",\"" k2 "\":\"" jesc(arr2[i]) "\"" \
|
|
409
|
+
(k3 != "" ? ",\"" k3 "\":\"" jesc(arr3[i]) "\"" : "") "}"
|
|
392
410
|
return out
|
|
393
411
|
}
|
|
394
412
|
# Every `<!-- waits: … -->` marker on a line, each value split on commas, in
|
|
@@ -555,6 +573,7 @@ function reset_state() {
|
|
|
555
573
|
delete branch_heading; delete waits_of; delete waits_set; delete waits_n
|
|
556
574
|
delete unread_waits_branch; delete unread_waits_value; n_unread_waits = 0
|
|
557
575
|
delete unread_heading_item_wave; delete unread_heading_item_branch; n_unread_heading_items = 0
|
|
576
|
+
delete unread_branch_item_wave; delete unread_branch_item_branch; delete unread_branch_item_line; n_unread_branch_items = 0
|
|
558
577
|
heading_branch = ""; heading_branch_n = 0
|
|
559
578
|
delete builds_of; delete agent_of; delete commits_of; delete started; n_started = 0
|
|
560
579
|
fm_changelog = ""
|
|
@@ -778,6 +797,7 @@ function emit_record( fmt, praw, palt_raw, traw, title, sprint, story, assigne
|
|
|
778
797
|
# store_waits(), so it stays silent, as today.
|
|
779
798
|
out = out ",\"unread_waits\":[" emit_pairs(n_unread_waits, "branch", unread_waits_branch, "value", unread_waits_value) "]"
|
|
780
799
|
out = out ",\"unread_heading_items\":[" emit_pairs(n_unread_heading_items, "wave", unread_heading_item_wave, "branch", unread_heading_item_branch) "]"
|
|
800
|
+
out = out ",\"unread_branch_items\":[" emit_pairs(n_unread_branch_items, "wave", unread_branch_item_wave, "branch", unread_branch_item_branch, "line", unread_branch_item_line) "]"
|
|
781
801
|
out = out ",\"review_raw\":\"" jesc(review) "\",\"review\":\"" norm_review(review) "\""
|
|
782
802
|
out = out ",\"impl_raw\":\"" jesc(impl) "\",\"impl\":\"" norm_impl(impl) "\""
|
|
783
803
|
out = out ",\"design_raw\":\"" jesc(design) "\""
|
|
@@ -1035,6 +1055,45 @@ function extract_prs(raw, defer, line, p) {
|
|
|
1035
1055
|
line = raw
|
|
1036
1056
|
while (match(line, /→#[0-9]+/)) { malformed_prs[++n_malformed_prs] = substr(line, RSTART, RLENGTH); line = substr(line, RSTART + RLENGTH) }
|
|
1037
1057
|
}
|
|
1058
|
+
# The first branch-prefixed token on a NON-CLAIM list item, read for
|
|
1059
|
+
# unread_branch_items. Scans $0 AS WRITTEN — backticks included — since the
|
|
1060
|
+
# 3819 line (`` - Umsetzung: `bug/…` ``) names its branch inside a code span,
|
|
1061
|
+
# unlike mask_code() callers, which strip spans before reading. A boundary
|
|
1062
|
+
# character ahead of the prefix keeps "feature/x" from matching inside a
|
|
1063
|
+
# longer word such as "mifeature/x"; none of the real prefixes end a word
|
|
1064
|
+
# that would otherwise collide.
|
|
1065
|
+
#
|
|
1066
|
+
# Three kinds of token read as something OTHER than a branch, and are
|
|
1067
|
+
# skipped rather than reported: `idea/` names a plan, not a branch a slice
|
|
1068
|
+
# can claim; a name holding `*` is a glob a plan writes to mean "every
|
|
1069
|
+
# branch"; and a `.` anywhere after the prefix means a file path
|
|
1070
|
+
# (`docs/plans/x.md`), since no branch name in this estate ever carries one.
|
|
1071
|
+
# Loops past a skipped token rather than stopping at the first
|
|
1072
|
+
# match, so a line naming an excluded token before a real one (prose citing
|
|
1073
|
+
# both an `idea/` plan and a `bug/` branch) still reports the real one.
|
|
1074
|
+
function unread_branch_token(s, re, tok, pfx, rest) {
|
|
1075
|
+
re = "(^|[^A-Za-z0-9_/-])(" PREFIXES ")/[^ \t,)`:]+"
|
|
1076
|
+
while (match(s, re)) {
|
|
1077
|
+
tok = substr(s, RSTART, RLENGTH)
|
|
1078
|
+
sub("^[^A-Za-z0-9_/-]*", "", tok)
|
|
1079
|
+
s = substr(s, RSTART + RLENGTH)
|
|
1080
|
+
pfx = tok; sub(/\/.*/, "", pfx)
|
|
1081
|
+
rest = substr(tok, length(pfx) + 2)
|
|
1082
|
+
if (pfx != "idea" && index(tok, "*") == 0 && index(rest, ".") == 0) return tok
|
|
1083
|
+
}
|
|
1084
|
+
return ""
|
|
1085
|
+
}
|
|
1086
|
+
# Records $0 into unread_branch_items when it is a non-claim list item naming
|
|
1087
|
+
# a branch token — the one guard and the one recording shape both slice
|
|
1088
|
+
# dialects share in their non-claim arm.
|
|
1089
|
+
function record_unread_branch_item( utok) {
|
|
1090
|
+
if ($0 !~ /^[ \t]*-[ \t]+/ || $0 ~ /<!--[ \t]*(deferred|moved)[ \t]*(:|-->)/) return
|
|
1091
|
+
utok = unread_branch_token($0)
|
|
1092
|
+
if (utok == "") return
|
|
1093
|
+
unread_branch_item_wave[++n_unread_branch_items] = (n_waves > 0 ? wave_names[n_waves] : "")
|
|
1094
|
+
unread_branch_item_branch[n_unread_branch_items] = utok
|
|
1095
|
+
unread_branch_item_line[n_unread_branch_items] = trim($0)
|
|
1096
|
+
}
|
|
1038
1097
|
# The longest wave name that still reads as a label, not prose. A JUDGEMENT, not
|
|
1039
1098
|
# a measurement: the longest legitimate name in the estate is `Offered first`
|
|
1040
1099
|
# (13), and the offender this exists to catch is a 53-character sentence, so the
|
|
@@ -1328,6 +1387,8 @@ section == "slices" && slice_shape != "heading" {
|
|
|
1328
1387
|
if (n_waves == 0) { wave_names[++n_waves] = "" }
|
|
1329
1388
|
wave_of[n_branches] = n_waves; ++wave_count[n_waves]
|
|
1330
1389
|
keep_branch(n_branches, b, 0)
|
|
1390
|
+
} else {
|
|
1391
|
+
record_unread_branch_item()
|
|
1331
1392
|
}
|
|
1332
1393
|
extract_prs($0)
|
|
1333
1394
|
next
|
|
@@ -1432,6 +1493,10 @@ section == "slices" && slice_shape == "heading" {
|
|
|
1432
1493
|
# reported rather than silently dropped and never read as a second claim.
|
|
1433
1494
|
unread_heading_item_wave[++n_unread_heading_items] = wave_names[n_waves]; unread_heading_item_branch[n_unread_heading_items] = item_branch
|
|
1434
1495
|
}
|
|
1496
|
+
} else {
|
|
1497
|
+
# Not a claim at all — a non-claim item in a `## Waves` section can still
|
|
1498
|
+
# name a branch in prose, exactly as a list item in the old shape can.
|
|
1499
|
+
record_unread_branch_item()
|
|
1435
1500
|
}
|
|
1436
1501
|
next
|
|
1437
1502
|
}
|