looply-cli 0.5.51 → 0.5.53
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/account-connect.d.ts +2 -1
- package/dist/account-connect.d.ts.map +1 -1
- package/dist/account-connect.js.map +1 -1
- package/dist/adaptive-budget.d.ts +6 -0
- package/dist/adaptive-budget.d.ts.map +1 -1
- package/dist/adaptive-budget.js +9 -0
- package/dist/adaptive-budget.js.map +1 -1
- package/dist/autonomy-controller.d.ts.map +1 -1
- package/dist/autonomy-controller.js +19 -0
- package/dist/autonomy-controller.js.map +1 -1
- package/dist/base-check-turns.d.ts +38 -0
- package/dist/base-check-turns.d.ts.map +1 -0
- package/dist/base-check-turns.js +118 -0
- package/dist/base-check-turns.js.map +1 -0
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +32 -2
- package/dist/bin.js.map +1 -1
- package/dist/branch-delivery.d.ts +48 -1
- package/dist/branch-delivery.d.ts.map +1 -1
- package/dist/branch-delivery.js +203 -4
- package/dist/branch-delivery.js.map +1 -1
- package/dist/bug-repro.d.ts +89 -9
- package/dist/bug-repro.d.ts.map +1 -1
- package/dist/bug-repro.js +242 -14
- package/dist/bug-repro.js.map +1 -1
- package/dist/checkout-carry.d.ts +31 -0
- package/dist/checkout-carry.d.ts.map +1 -1
- package/dist/checkout-carry.js +98 -3
- package/dist/checkout-carry.js.map +1 -1
- package/dist/checkout-deps.d.ts +2 -0
- package/dist/checkout-deps.d.ts.map +1 -1
- package/dist/checkout-deps.js +2 -0
- package/dist/checkout-deps.js.map +1 -1
- package/dist/daemon-cmd.d.ts +1 -1
- package/dist/daemon-cmd.d.ts.map +1 -1
- package/dist/daemon-cmd.js +10 -3
- package/dist/daemon-cmd.js.map +1 -1
- package/dist/fresh-gates.d.ts.map +1 -1
- package/dist/fresh-gates.js +13 -0
- package/dist/fresh-gates.js.map +1 -1
- package/dist/gate-health.d.ts +2 -0
- package/dist/gate-health.d.ts.map +1 -1
- package/dist/gate-health.js +41 -4
- package/dist/gate-health.js.map +1 -1
- package/dist/goal-adaptive.d.ts +45 -3
- package/dist/goal-adaptive.d.ts.map +1 -1
- package/dist/goal-adaptive.js +104 -16
- package/dist/goal-adaptive.js.map +1 -1
- package/dist/goal-already-met.d.ts +62 -0
- package/dist/goal-already-met.d.ts.map +1 -0
- package/dist/goal-already-met.js +95 -0
- package/dist/goal-already-met.js.map +1 -0
- package/dist/goal-execution-evidence.d.ts +7 -1
- package/dist/goal-execution-evidence.d.ts.map +1 -1
- package/dist/goal-execution-evidence.js +12 -1
- package/dist/goal-execution-evidence.js.map +1 -1
- package/dist/goal-gap.d.ts +48 -5
- package/dist/goal-gap.d.ts.map +1 -1
- package/dist/goal-gap.js +103 -13
- package/dist/goal-gap.js.map +1 -1
- package/dist/integration-deps.d.ts.map +1 -1
- package/dist/integration-deps.js +18 -0
- package/dist/integration-deps.js.map +1 -1
- package/dist/machine-settings.d.ts +9 -0
- package/dist/machine-settings.d.ts.map +1 -1
- package/dist/machine-settings.js +35 -2
- package/dist/machine-settings.js.map +1 -1
- package/dist/output-gist.d.ts +40 -0
- package/dist/output-gist.d.ts.map +1 -0
- package/dist/output-gist.js +107 -0
- package/dist/output-gist.js.map +1 -0
- package/dist/plan-recovery.d.ts +14 -3
- package/dist/plan-recovery.d.ts.map +1 -1
- package/dist/plan-recovery.js +24 -6
- package/dist/plan-recovery.js.map +1 -1
- package/dist/provider-accounts.d.ts +0 -6
- package/dist/provider-accounts.d.ts.map +1 -1
- package/dist/provider-accounts.js +0 -6
- package/dist/provider-accounts.js.map +1 -1
- package/dist/pursuit-ending.d.ts.map +1 -1
- package/dist/pursuit-ending.js +11 -0
- package/dist/pursuit-ending.js.map +1 -1
- package/dist/quarantine-report.d.ts +32 -0
- package/dist/quarantine-report.d.ts.map +1 -0
- package/dist/quarantine-report.js +75 -0
- package/dist/quarantine-report.js.map +1 -0
- package/dist/round-runner.d.ts +13 -2
- package/dist/round-runner.d.ts.map +1 -1
- package/dist/round-runner.js +5 -1
- package/dist/round-runner.js.map +1 -1
- package/dist/run-cmd.d.ts.map +1 -1
- package/dist/run-cmd.js +84 -11
- package/dist/run-cmd.js.map +1 -1
- package/dist/self-update.d.ts.map +1 -1
- package/dist/self-update.js +5 -15
- package/dist/self-update.js.map +1 -1
- package/dist/serve-cmd.d.ts +9 -0
- package/dist/serve-cmd.d.ts.map +1 -1
- package/dist/serve-cmd.js +45 -1
- package/dist/serve-cmd.js.map +1 -1
- package/dist/serve-log.d.ts +52 -0
- package/dist/serve-log.d.ts.map +1 -0
- package/dist/serve-log.js +146 -0
- package/dist/serve-log.js.map +1 -0
- package/dist/serve.d.ts +7 -7
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +11 -15
- package/dist/serve.js.map +1 -1
- package/dist/server-client.d.ts +14 -2
- package/dist/server-client.d.ts.map +1 -1
- package/dist/server-client.js +24 -2
- package/dist/server-client.js.map +1 -1
- package/dist/setup-check-wiring.d.ts +8 -0
- package/dist/setup-check-wiring.d.ts.map +1 -1
- package/dist/setup-check-wiring.js +78 -22
- package/dist/setup-check-wiring.js.map +1 -1
- package/dist/setup-check.d.ts +4 -0
- package/dist/setup-check.d.ts.map +1 -1
- package/dist/setup-check.js +70 -3
- package/dist/setup-check.js.map +1 -1
- package/dist/steady-log.d.ts +48 -0
- package/dist/steady-log.d.ts.map +1 -0
- package/dist/steady-log.js +100 -0
- package/dist/steady-log.js.map +1 -0
- package/dist/verify-cmd.d.ts +0 -2
- package/dist/verify-cmd.d.ts.map +1 -1
- package/dist/verify-cmd.js +0 -5
- package/dist/verify-cmd.js.map +1 -1
- package/dist/workspace-builds.d.ts +153 -0
- package/dist/workspace-builds.d.ts.map +1 -0
- package/dist/workspace-builds.js +347 -0
- package/dist/workspace-builds.js.map +1 -0
- package/dist/workspace-quarantine.d.ts +36 -2
- package/dist/workspace-quarantine.d.ts.map +1 -1
- package/dist/workspace-quarantine.js +53 -0
- package/dist/workspace-quarantine.js.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +11 -3
- package/dist/workspace.js.map +1 -1
- package/package.json +2 -2
- package/win/contained-node.cjs +110 -1
- package/dist/.src-hash +0 -1
package/dist/branch-delivery.js
CHANGED
|
@@ -11,6 +11,8 @@ exports.findGoalBranch = findGoalBranch;
|
|
|
11
11
|
exports.stackedOn = stackedOn;
|
|
12
12
|
exports.partsLine = partsLine;
|
|
13
13
|
exports.summarizeChanges = summarizeChanges;
|
|
14
|
+
exports.conflictFilesOf = conflictFilesOf;
|
|
15
|
+
exports.deliveryConflictOf = deliveryConflictOf;
|
|
14
16
|
exports.deliveryStall = deliveryStall;
|
|
15
17
|
exports.pullTitle = pullTitle;
|
|
16
18
|
exports.maintenanceSection = maintenanceSection;
|
|
@@ -29,6 +31,7 @@ exports.noNewCommits = noNewCommits;
|
|
|
29
31
|
exports.conflictMoved = conflictMoved;
|
|
30
32
|
exports.ticketAttemptOf = ticketAttemptOf;
|
|
31
33
|
exports.ticketAttemptOfMember = ticketAttemptOfMember;
|
|
34
|
+
exports.replacementOf = replacementOf;
|
|
32
35
|
exports.herokuLoginSentence = herokuLoginSentence;
|
|
33
36
|
exports.herokuAuthRefusal = herokuAuthRefusal;
|
|
34
37
|
exports.makeReleaseRunner = makeReleaseRunner;
|
|
@@ -397,7 +400,50 @@ function summarizeChanges(numstat, log) {
|
|
|
397
400
|
truncated: files.length > core_3.MAX_CHANGED_FILES || commits.length > core_3.MAX_CHANGED_COMMITS,
|
|
398
401
|
};
|
|
399
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* The files a conflict rebuild's refusal names, in its own words (`branch-replay.ts`: "… (it conflicts in a.ts,
|
|
405
|
+
* b.ts)", git's "patch failed: package.json:19"). Read from the words so an entry held before the files were
|
|
406
|
+
* reported (RBB-T-14's, on the owner's machine now) reports them too. At most six, as the refusal itself lists.
|
|
407
|
+
*/
|
|
408
|
+
function conflictFilesOf(because) {
|
|
409
|
+
const s = (because ?? '').replace(/\s+/g, ' ');
|
|
410
|
+
const files = [];
|
|
411
|
+
const add = (p) => {
|
|
412
|
+
const f = p.trim().replace(/:\d+$/, '');
|
|
413
|
+
if (f !== '' && f !== '…' && /^[\w@./+-]+$/.test(f) && !files.includes(f))
|
|
414
|
+
files.push(f);
|
|
415
|
+
};
|
|
416
|
+
// The closing bracket may be cut off: the reason is kept to 300 characters.
|
|
417
|
+
const named = /\bit conflicts in ([^)]+)\)?/.exec(s);
|
|
418
|
+
if (named !== null) {
|
|
419
|
+
const listed = named[1].split(/,\s*/);
|
|
420
|
+
// The reason is kept to 300 characters with nothing to mark the cut: a list with no closing bracket may end in
|
|
421
|
+
// half a path ("src/routes/que"), which is not a file. Its last name is left out.
|
|
422
|
+
if (!/\bit conflicts in [^)]+\)/.test(s))
|
|
423
|
+
listed.pop();
|
|
424
|
+
for (const p of listed)
|
|
425
|
+
add(p);
|
|
426
|
+
}
|
|
427
|
+
for (const m of s.matchAll(/\bpatch failed: ([^\s:;)]+):\d+/g))
|
|
428
|
+
add(m[1]);
|
|
429
|
+
return files.slice(0, 6);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* 🔴 THE CONFLICT AS DATA, FOR AutoRyn (RBB-T-14, 2026-11-16: it was in the note only, and AutoRyn read it from the
|
|
433
|
+
* wording). Set only while the pull request is held because it conflicts with its base and Looply could not bring
|
|
434
|
+
* it up to date by itself; null once it no longer conflicts, once it was rebuilt, once a replacement is open in its
|
|
435
|
+
* place, and once nothing is left to do on it.
|
|
436
|
+
*/
|
|
437
|
+
function deliveryConflictOf(e) {
|
|
438
|
+
if (!e.conflict || e.state !== 'pr-open' || e.done === true || e.replacedBy)
|
|
439
|
+
return null;
|
|
440
|
+
const base = e.conflict.base ?? e.projectBase ?? e.base;
|
|
441
|
+
if (!base)
|
|
442
|
+
return null;
|
|
443
|
+
return { base, files: conflictFilesOf(e.conflict.because) };
|
|
444
|
+
}
|
|
400
445
|
function reportOf(e) {
|
|
446
|
+
const conflict = deliveryConflictOf(e);
|
|
401
447
|
return {
|
|
402
448
|
state: e.state,
|
|
403
449
|
branch: e.branch,
|
|
@@ -410,6 +456,8 @@ function reportOf(e) {
|
|
|
410
456
|
deploy: e.deploy ?? null,
|
|
411
457
|
...(e.environments === undefined ? {} : { environments: e.environments }),
|
|
412
458
|
...(e.changes ? { changes: e.changes } : {}),
|
|
459
|
+
...(e.reproduction ? { reproduction: e.reproduction } : {}),
|
|
460
|
+
...(conflict === null ? {} : { conflict }),
|
|
413
461
|
};
|
|
414
462
|
}
|
|
415
463
|
/**
|
|
@@ -675,6 +723,7 @@ async function deliverOnce(deps, input) {
|
|
|
675
723
|
dependsOn: stack?.branch ?? null,
|
|
676
724
|
state: 'pushed',
|
|
677
725
|
...(rebuilt === null ? {} : { rebuiltFrom: { branch: original.name, sha: original.sha, without: rebuilt.without } }),
|
|
726
|
+
...(input.reproduction ? { reproduction: input.reproduction } : {}),
|
|
678
727
|
};
|
|
679
728
|
if (gh === null) {
|
|
680
729
|
return save(deps, { ...entry, note: `pushed to origin (${remoteUrl === null ? 'no URL' : (0, delivery_rules_1.redactUrl)(remoteUrl)}); origin is not on github.com, so no pull request was opened` });
|
|
@@ -1174,6 +1223,13 @@ async function advanceDeliveries(deps) {
|
|
|
1174
1223
|
catch (err) {
|
|
1175
1224
|
deps.log(`deliver : superseded pull requests: ${err.message}`);
|
|
1176
1225
|
}
|
|
1226
|
+
// Before the pass below, so a conflicted pull request whose replacement is open is never rebuilt again.
|
|
1227
|
+
try {
|
|
1228
|
+
await closeReplaced(deps);
|
|
1229
|
+
}
|
|
1230
|
+
catch (err) {
|
|
1231
|
+
deps.log(`deliver : replaced pull requests: ${err.message}`);
|
|
1232
|
+
}
|
|
1177
1233
|
for (const e of deps.store.all()) {
|
|
1178
1234
|
if (!ADVANCING.includes(e.state))
|
|
1179
1235
|
continue;
|
|
@@ -1197,8 +1253,8 @@ async function advanceOne(deps, e) {
|
|
|
1197
1253
|
// 🔴 SHIP TO TEST'S SAFETY, asked again on every pass: settings that changed since the delivery count.
|
|
1198
1254
|
const safe = effectiveMode(asked, { deploy: deps.deploy(), environments: deps.environments?.() ?? [] });
|
|
1199
1255
|
const mode = safe.mode;
|
|
1200
|
-
// A person's approval, read from the goal mirror.
|
|
1201
|
-
if (!e.approvedAt && APPROVABLE.includes(e.state) && e.pullNumber !== null) {
|
|
1256
|
+
// A person's approval, read from the goal mirror. A replaced one is final: its replacement is what ships.
|
|
1257
|
+
if (!e.approvedAt && !e.replacedBy && APPROVABLE.includes(e.state) && e.pullNumber !== null) {
|
|
1202
1258
|
const approved = deps.shipRequested(e.goalId);
|
|
1203
1259
|
if (approved !== null && approved !== e.voidedApproval) {
|
|
1204
1260
|
// 🔴 A BLOCKED ONE STAYS BLOCKED: the approval is kept, and acted on once it unblocks.
|
|
@@ -1241,7 +1297,16 @@ async function advanceOne(deps, e) {
|
|
|
1241
1297
|
await followDeploys(deps, api, e, wantsDeploy, mode);
|
|
1242
1298
|
}
|
|
1243
1299
|
else if (pull.state === 'closed') {
|
|
1244
|
-
await save(deps, { ...e, done: true, note: 'the pull request was closed without merging; Looply leaves it', updatedAt: at });
|
|
1300
|
+
await save(deps, { ...e, done: true, note: e.replacedBy ? e.note : 'the pull request was closed without merging; Looply leaves it', updatedAt: at });
|
|
1301
|
+
}
|
|
1302
|
+
else if (e.replacedBy) {
|
|
1303
|
+
/**
|
|
1304
|
+
* 🔴 REPLACED: NEVER REBUILT, RE-JUDGED OR MERGED AGAIN (RBB-T-14, 2026-11-16). Its replacement makes the same
|
|
1305
|
+
* change on the current base; rebuilding this one too whenever the base moved was wasted work, noise on the
|
|
1306
|
+
* ticket, and — had a rebuild ever worked — a second pull request with the same change. Only a person's own
|
|
1307
|
+
* merge or close of it (above) is still recorded.
|
|
1308
|
+
*/
|
|
1309
|
+
return;
|
|
1245
1310
|
}
|
|
1246
1311
|
else if (
|
|
1247
1312
|
/**
|
|
@@ -1359,6 +1424,12 @@ async function advanceOne(deps, e) {
|
|
|
1359
1424
|
await save(deps, { ...e, mode, state: 'waiting-checks', conflict: null, waitingSince: at, note: `it no longer conflicts with ${base}; merging once the checks allow`, updatedAt: at });
|
|
1360
1425
|
return;
|
|
1361
1426
|
}
|
|
1427
|
+
else if (e.state === 'pr-open' && e.conflict && pull.conflicted === false && !wantsMerge && pull.state === 'open') {
|
|
1428
|
+
// The same, after the project went back to "pr": it is a person's to merge, and the report no longer says it conflicts.
|
|
1429
|
+
const base = e.projectBase ?? pull.base;
|
|
1430
|
+
await save(deps, { ...e, mode, conflict: null, note: `it no longer conflicts with ${base}; a person merges`, updatedAt: at });
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1362
1433
|
else if (
|
|
1363
1434
|
/**
|
|
1364
1435
|
* PARKED ONLY FOR WANT OF CI, AND THAT NO LONGER HOLDS: under ship to test, a pull request
|
|
@@ -1710,7 +1781,7 @@ async function rebuildOnBase(deps, api, e, pull, at, mode) {
|
|
|
1710
1781
|
const note = `not merged: it conflicts with ${base}, and Looply could not rebuild it on the current ${base} (${because}); a person resolves the conflict`.slice(0, 600);
|
|
1711
1782
|
if (e.state !== 'pr-open' || e.note !== note)
|
|
1712
1783
|
deps.log(`deliver : ${e.goalId}: ${note}`);
|
|
1713
|
-
await save(deps, { ...e, mode, state: 'pr-open', conflict: { head, baseSha: pull.baseSha ?? '', because: because.slice(0, 300), at }, note, updatedAt: at });
|
|
1784
|
+
await save(deps, { ...e, mode, state: 'pr-open', conflict: { head, baseSha: pull.baseSha ?? '', because: because.slice(0, 300), at, base }, note, updatedAt: at });
|
|
1714
1785
|
};
|
|
1715
1786
|
if (pull.draft === true)
|
|
1716
1787
|
return held('it is a draft, so a person is still working on it');
|
|
@@ -2044,6 +2115,134 @@ async function supersede(deps, old, newer) {
|
|
|
2044
2115
|
}
|
|
2045
2116
|
return true;
|
|
2046
2117
|
}
|
|
2118
|
+
/* ───────────────────────────── a fix-up that makes the change again ── */
|
|
2119
|
+
/** `url` named as itself in `text`: not as the start of a longer one (`/pull/1` is not `/pull/19`). */
|
|
2120
|
+
function mentions(text, needle) {
|
|
2121
|
+
return new RegExp(`(?<![\\w/.-])${escapeRe(needle)}(?![\\w/#-])`).test(text);
|
|
2122
|
+
}
|
|
2123
|
+
/** "replaces <url>", the way AutoRyn's fix-up ends ("This replaces https://github.com/o/r/pull/19."). */
|
|
2124
|
+
function saysReplaces(text, url) {
|
|
2125
|
+
return new RegExp(`\\breplaces\\s+${escapeRe(url)}(?![\\w/#-])`, 'i').test(text);
|
|
2126
|
+
}
|
|
2127
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
2128
|
+
/**
|
|
2129
|
+
* States in which a delivery has its own pull request that can take the old one's place, on Looply's last read: open
|
|
2130
|
+
* and not failing, or merged. 🔴 NOT `checks-failed` or `blocked` (review of 0.5.53): closing the old one for a
|
|
2131
|
+
* replacement that cannot merge either would leave the ticket with nothing but a red pull request. It is closed on a
|
|
2132
|
+
* later pass, once the replacement's checks pass.
|
|
2133
|
+
*/
|
|
2134
|
+
const WITH_PULL = ['pr-open', 'waiting-checks', 'merged', 'deployed', 'deploy-failed'];
|
|
2135
|
+
/** AutoRyn's fix-up for a conflict, in its own words (followThrough: "… make the same change again — the commits on <branch> show what it was …"). */
|
|
2136
|
+
const MAKES_IT_AGAIN = /\bmake the same change again\b|\bbring this change up to date\b/i;
|
|
2137
|
+
/**
|
|
2138
|
+
* 🔴 WHICH DELIVERY REPLACES THIS ONE — the newest that does, or null. Pure (RBB-T-14, 2026-11-16).
|
|
2139
|
+
*
|
|
2140
|
+
* A pull request that conflicts with its base, and that Looply could not bring up to date by itself, goes back to
|
|
2141
|
+
* Looply as a NEW goal on the same ticket: AutoRyn's fix-up, cut from the current base with no `dependsOn`, whose
|
|
2142
|
+
* words end "… This replaces <the old pull request's address>." Its pull request does not contain the old head and
|
|
2143
|
+
* asks for different words, so neither rule in `closeSuperseded` fires, and `replacing` in `deliverOnce` takes only a
|
|
2144
|
+
* `checks-failed` predecessor. A newer delivery replaces `old` when it has its own pull request in the same
|
|
2145
|
+
* repository, not built on `old`'s branch, and either
|
|
2146
|
+
* - its goal says "replaces <old's address>" (what AutoRyn's fix-up says), or
|
|
2147
|
+
* - it is a later attempt at the same ticket (`clientRef`), `old` is held on a conflict, and its goal names old's
|
|
2148
|
+
* address or branch — the same lineage without the last sentence (AutoRyn caps a goal's words at 2000
|
|
2149
|
+
* characters, and that sentence comes last).
|
|
2150
|
+
* `old` must be Looply's own run branch's pull request, still open to Looply, and not already replaced.
|
|
2151
|
+
*/
|
|
2152
|
+
function replacementOf(old, all, refOf = (e) => e.clientRef ?? null) {
|
|
2153
|
+
const url = old.pullRequestUrl;
|
|
2154
|
+
if (url === null || old.pullNumber === null || old.owner === null || old.repo === null)
|
|
2155
|
+
return null;
|
|
2156
|
+
if (old.done === true || old.replacedBy || !OPEN_STATES.includes(old.state) || !old.branch.startsWith(integrator_1.RUN_BRANCH_PREFIX))
|
|
2157
|
+
return null;
|
|
2158
|
+
// 🔴 ONLY A PULL REQUEST THAT CANNOT GO IN AS IT IS (review of 0.5.53): held on a conflict, or failing its checks.
|
|
2159
|
+
// A healthy one is never closed because a later goal's words name it — whatever they say.
|
|
2160
|
+
if (!old.conflict && old.state !== 'checks-failed')
|
|
2161
|
+
return null;
|
|
2162
|
+
const mine = ticketAttemptOfMember(refOf(old));
|
|
2163
|
+
const oldBranches = [old.branch, old.rebuiltFrom?.branch].filter((b) => typeof b === 'string');
|
|
2164
|
+
const found = all.filter((n) => {
|
|
2165
|
+
if (n.goalId === old.goalId || n.owner !== old.owner || n.repo !== old.repo)
|
|
2166
|
+
return false;
|
|
2167
|
+
if (n.pullNumber === null || n.pullNumber === old.pullNumber || n.pullRequestUrl === null || n.pullRequestUrl === url)
|
|
2168
|
+
return false;
|
|
2169
|
+
if (!WITH_PULL.includes(n.state) || (n.done === true && !MERGED.includes(n.state)) || n.replacedBy)
|
|
2170
|
+
return false;
|
|
2171
|
+
if ((n.base !== null && oldBranches.includes(n.base)) || (n.dependsOn !== null && oldBranches.includes(n.dependsOn)))
|
|
2172
|
+
return false;
|
|
2173
|
+
if (saysReplaces(n.goalText, url))
|
|
2174
|
+
return true;
|
|
2175
|
+
const theirs = ticketAttemptOfMember(refOf(n));
|
|
2176
|
+
return (!!old.conflict &&
|
|
2177
|
+
mine !== null &&
|
|
2178
|
+
theirs !== null &&
|
|
2179
|
+
theirs.ticket === mine.ticket &&
|
|
2180
|
+
theirs.attempt > mine.attempt &&
|
|
2181
|
+
// 🔴 NOT A MERE MENTION (review of 0.5.53): a QA send-back that quotes the old address ("on top of #19, also
|
|
2182
|
+
// fix the label") does not contain the old change. The later attempt must be told to MAKE THE CHANGE AGAIN.
|
|
2183
|
+
MAKES_IT_AGAIN.test(n.goalText) &&
|
|
2184
|
+
(mentions(n.goalText, url) || mentions(n.goalText, old.branch)));
|
|
2185
|
+
});
|
|
2186
|
+
return [...found].sort((a, b) => Date.parse(b.openedAt) - Date.parse(a.openedAt))[0] ?? null;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* 🔴 THE OLD PULL REQUEST IS CLOSED ONCE ITS REPLACEMENT IS OPEN (RBB-T-14, ButtKick3r/RobinBet#19, 2026-11-16: the
|
|
2190
|
+
* conflicted pull request would have stayed open for ever beside the fix-up's).
|
|
2191
|
+
*
|
|
2192
|
+
* Never before: GitHub, read now, must say the replacement is merged, or open and not a draft — never close the old
|
|
2193
|
+
* one while nothing replaces it. Never when the old one is merged or closed already (the normal pass records that).
|
|
2194
|
+
* Closed with one comment that names the replacement; its branch is left where it is. Kept open — final all the
|
|
2195
|
+
* same, never rebuilt again, saying why on the ticket once — when closing it could lose somebody's work: a draft,
|
|
2196
|
+
* a head somebody else pushed, or pull requests built on its branch.
|
|
2197
|
+
*/
|
|
2198
|
+
async function closeReplaced(deps) {
|
|
2199
|
+
const all = deps.store.all();
|
|
2200
|
+
const refOf = (e) => e.clientRef ?? deps.clientRefOf?.(e.goalId) ?? null;
|
|
2201
|
+
for (const old of all) {
|
|
2202
|
+
const newer = replacementOf(old, all, refOf);
|
|
2203
|
+
if (newer === null)
|
|
2204
|
+
continue;
|
|
2205
|
+
try {
|
|
2206
|
+
await replaceWith(deps, deps.store.get(old.goalId) ?? old, newer);
|
|
2207
|
+
}
|
|
2208
|
+
catch (err) {
|
|
2209
|
+
deps.log(`deliver : ${old.goalId}: could not close it as replaced by ${newer.pullRequestUrl} (${err.message}); tried again next pass`);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
async function replaceWith(deps, old, newer) {
|
|
2214
|
+
const client = await deps.github(old.owner, old.repo);
|
|
2215
|
+
if (client.api === null)
|
|
2216
|
+
return; // no credentials right now: next pass
|
|
2217
|
+
const api = client.api;
|
|
2218
|
+
const theirs = await api.getPull(newer.pullNumber);
|
|
2219
|
+
if (!theirs.merged && (theirs.state !== 'open' || theirs.draft === true))
|
|
2220
|
+
return; // nothing replaces it yet
|
|
2221
|
+
const pull = await api.getPull(old.pullNumber);
|
|
2222
|
+
if (pull.merged || pull.state !== 'open')
|
|
2223
|
+
return; // the normal pass records what happened to it
|
|
2224
|
+
const at = new Date(deps.now()).toISOString();
|
|
2225
|
+
const base = old.conflict?.base ?? old.projectBase ?? pull.base;
|
|
2226
|
+
const url = newer.pullRequestUrl;
|
|
2227
|
+
const replacedBy = { goalId: newer.goalId, url, at };
|
|
2228
|
+
const built = dependents(deps.store, old);
|
|
2229
|
+
const keep = pull.draft === true
|
|
2230
|
+
? 'it is a draft, so a person is working on it'
|
|
2231
|
+
: pull.headSha !== '' && pull.headSha !== old.sha
|
|
2232
|
+
? 'somebody pushed to it since Looply opened it'
|
|
2233
|
+
: built.length > 0
|
|
2234
|
+
? `${built.map((d) => d.pullRequestUrl ?? `#${d.pullNumber}`).join(', ')} ${built.length === 1 ? 'builds' : 'build'} on its branch`
|
|
2235
|
+
: null;
|
|
2236
|
+
if (keep !== null) {
|
|
2237
|
+
const note = `replaced by ${url}, which makes this change again on the current ${base}; Looply does not rebuild it again, and leaves it open because ${keep}; a person closes it`;
|
|
2238
|
+
deps.log(`deliver : ${old.goalId}: ${note}`);
|
|
2239
|
+
await save(deps, { ...old, state: 'pr-open', replacedBy, note, updatedAt: at });
|
|
2240
|
+
return;
|
|
2241
|
+
}
|
|
2242
|
+
await api.closePull(old.pullNumber, `Replaced by #${newer.pullNumber}, which rebuilds this change on the current ${base}.`);
|
|
2243
|
+
deps.log(`deliver : ${old.goalId}: closed ${old.pullRequestUrl}, replaced by ${url}, which rebuilds it on the current ${base}`);
|
|
2244
|
+
await save(deps, { ...old, state: 'pr-open', done: true, replacedBy, note: `replaced by ${url}, which makes this change again on the current ${base}; closed`, updatedAt: at });
|
|
2245
|
+
}
|
|
2047
2246
|
/* ────────────────────────────────────────── where the merge got to ── */
|
|
2048
2247
|
/** How long a merged commit's deploys are followed for, so one done outside Looply is still seen. */
|
|
2049
2248
|
exports.FOLLOW_DEPLOYS_MS = 14 * 24 * 60 * 60_000;
|