@biffo/cli 0.265.1 → 0.265.3
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/index.js +1057 -54
- package/package.json +1 -1
- package/scripts/claim.sh +54 -7
package/package.json
CHANGED
package/scripts/claim.sh
CHANGED
|
@@ -235,6 +235,49 @@ remote_branches() {
|
|
|
235
235
|
fi
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
# --- the structural claim predicate (#1411, class #1362 instance 8) ---------
|
|
239
|
+
#
|
|
240
|
+
# "Does this open PR claim issue $1?" used to be answered independently at
|
|
241
|
+
# THREE call sites -- the `--guard` open-PR check, the plain-path open-PR
|
|
242
|
+
# check, and (before #1281/#1311) a fourth that scanned body text for any
|
|
243
|
+
# mention at all. Three copies of one question drift, which is exactly how
|
|
244
|
+
# this class keeps recurring (#1281, #1311, #1327 were all this same guard,
|
|
245
|
+
# fixed three separate times). This is now the ONE place the question is
|
|
246
|
+
# answered, called from both surviving sites.
|
|
247
|
+
#
|
|
248
|
+
# Emits the boolean body of a jq `select(...)` over a PR object carrying
|
|
249
|
+
# `number`/`headRefName`/`closingIssuesReferences`/`body`. Three signals, and
|
|
250
|
+
# each one is either GitHub's own structured answer or this estate's own
|
|
251
|
+
# documented convention -- never a bare "does the text mention #N anywhere"
|
|
252
|
+
# scan, which is what #1327 and #1311 both were:
|
|
253
|
+
#
|
|
254
|
+
# 1. `closingIssuesReferences` -- GitHub's OWN parse of a recognised closing
|
|
255
|
+
# keyword (Closes/Fixes/Resolves and their inflections). Authoritative;
|
|
256
|
+
# never re-derived by a regex here.
|
|
257
|
+
# 2. the branch name (`<type>/<number>-slug`), the same test used
|
|
258
|
+
# elsewhere in this file.
|
|
259
|
+
# 3. the PR body, but ONLY AGENTS.md's own `Refs #N` convention -- the form
|
|
260
|
+
# this estate mandates for a PR that must reference an issue WITHOUT
|
|
261
|
+
# closing it (DDL PRs, "instance of a class" PRs like this one). A
|
|
262
|
+
# claiming keyword (`refs`/`ref`/`references`/`reference`, case
|
|
263
|
+
# insensitive) must be immediately followed by `#N` on the SAME LINE.
|
|
264
|
+
# `\s` matches a newline, which is precisely the shape #1334 found in
|
|
265
|
+
# GitHub's own closing-keyword parser (a keyword ending one line, `#N`
|
|
266
|
+
# starting the next); this uses `[ \t]` instead, so a keyword and a
|
|
267
|
+
# reference split across a line break -- or a bare mention of `#N` with
|
|
268
|
+
# no keyword at all -- cannot match. A prose sentence like "this does
|
|
269
|
+
# NOT claim #N" carries no claiming keyword adjacent to the `#N` and so
|
|
270
|
+
# correctly does not match either (#1327, #1311's exact shape).
|
|
271
|
+
#
|
|
272
|
+
# $2 is the repo slug (`owner/name`) the closing-reference check compares
|
|
273
|
+
# against -- callers already resolve this via `repo_slug()` before calling.
|
|
274
|
+
claim_select_expr() {
|
|
275
|
+
_n="$1"
|
|
276
|
+
_slug="$2"
|
|
277
|
+
printf '(([.closingIssuesReferences[]? | select(.number == %s and ((.repository.owner.login + "/" + .repository.name) == "%s"))] | length > 0) or (.headRefName | test("(^|[^0-9A-Za-z])%s([^0-9A-Za-z]|$)")) or ((.body // "") | test("(^|[^0-9A-Za-z])(refs?|references?)[ \\t]*:?[ \\t]*#%s([^0-9A-Za-z]|$)"; "i")))' \
|
|
278
|
+
"$_n" "$_slug" "$_n" "$_n"
|
|
279
|
+
}
|
|
280
|
+
|
|
238
281
|
LABEL=in-progress
|
|
239
282
|
|
|
240
283
|
# --- holder identity (#1279) -------------------------------------------------
|
|
@@ -323,9 +366,9 @@ if [ -n "$GUARD_BRANCH" ]; then
|
|
|
323
366
|
# --- an open PR referencing the issue, excluding our own branch's PR --------
|
|
324
367
|
slug=$(repo_slug)
|
|
325
368
|
pr_err=$(mktemp)
|
|
326
|
-
|
|
327
|
-
open_prs=$(gh_pr list --state open --limit 100 --json number,headRefName,closingIssuesReferences \
|
|
328
|
-
--jq "[.[] | select(
|
|
369
|
+
select_expr=$(claim_select_expr "$guard_issue" "$slug")
|
|
370
|
+
open_prs=$(gh_pr list --state open --limit 100 --json number,headRefName,closingIssuesReferences,body \
|
|
371
|
+
--jq "[.[] | select($select_expr)] | .[] | select(.headRefName != \"$GUARD_BRANCH\") | \"#\(.number) \(.headRefName)\"" \
|
|
329
372
|
2>"$pr_err")
|
|
330
373
|
pr_status=$?
|
|
331
374
|
pr_err_text=$(cat "$pr_err")
|
|
@@ -432,12 +475,16 @@ esac
|
|
|
432
475
|
# --- 2. An open PR that references it ----------------------------------------
|
|
433
476
|
#
|
|
434
477
|
# The strongest signal, because a PR cannot be opened without the work existing.
|
|
435
|
-
#
|
|
436
|
-
#
|
|
478
|
+
# Uses `claim_select_expr` (above) -- the same structural predicate the
|
|
479
|
+
# `--guard` path uses -- so a `Closes #N`, a branch naming N, or a `Refs #N`
|
|
480
|
+
# (this estate's own convention for a PR that must not close its issue, e.g.
|
|
481
|
+
# a DDL PR) are all detected identically in both places, and a bare mention of
|
|
482
|
+
# `#N` in prose is not (#1281, #1311, #1327; #1411 is the `Refs` gap).
|
|
437
483
|
|
|
438
484
|
slug=$(repo_slug)
|
|
439
|
-
|
|
440
|
-
|
|
485
|
+
select_expr=$(claim_select_expr "$ISSUE" "$slug")
|
|
486
|
+
open_prs=$(gh_pr list --state open --limit 100 --json number,headRefName,closingIssuesReferences,body \
|
|
487
|
+
--jq "[.[] | select($select_expr)] | .[] | \"#\(.number) \(.headRefName)\"" 2>/dev/null)
|
|
441
488
|
|
|
442
489
|
if [ -n "$open_prs" ]; then
|
|
443
490
|
printf '%s\n' "$open_prs" | while IFS= read -r pr; do
|