Public: anyone can read this; the crew can change it.
Reverts need two reds on the same test, and close themselves when main goes green #16721
Check · Review · Land · Live done — Landed and live in production.
flow/revert-policy → main 0 commits 1 thread · 1 unresolved
5 files
changed +238
−17
docs/OPERATING.md +1 −1
Diff not shown — a line 2,743 characters wide (limit 2,000). +1 −1
View filesrc/checks/culprit.ts +124 −5
| @@ -12,13 +12,23 @@ | ||
| 12 | 12 | * A later green verification that ran every file such an issue names |
| 13 | 13 | * closes it as done (#11395), unless a person has commented on it. |
| 14 | 14 | * |
| 15 | * A revert waits for a second opinion: it is proposed only when two | |
| 16 | * consecutive red verifications fail the same test with the culprit in both | |
| 17 | * (the later one, red since the same last green, would bisect to the same | |
| 18 | * commit). 41 of 43 reverts proposed on one red were wrong: main went green | |
| 19 | * again with the target still in it, a median 148 minutes later. A green | |
| 20 | * verification that passes every file a forge-proposed revert names, with its | |
| 21 | * target still on main, closes that revert with the reason in one line. | |
| 22 | * | |
| 15 | 23 | * Called by the checks service with the way it asks for a run; the answer |
| 16 | 24 | * is the lines for the finished run's log. |
| 17 | 25 | */ |
| 18 | 26 | |
| 19 | 27 | import type { App } from "../app.ts"; |
| 20 | 28 | import { revertPull } from "../actions/revert.ts"; |
| 21 | import { addComment, createIssue, setIssueState } from "../core/issues.ts"; | |
| 29 | import { deleteBranch } from "../actions/branches.ts"; | |
| 30 | import { addComment as commentAs, setIssueState as closeAs } from "../actions/issues.ts"; | |
| 31 | import { addComment, createIssue, getIssueById, setIssueState } from "../core/issues.ts"; | |
| 22 | 32 | import { getPull, type Pull } from "../core/pulls.ts"; |
| 23 | 33 | import type { Repo } from "../core/repos.ts"; |
| 24 | 34 | import { getRun, type Run } from "../core/runs.ts"; |
| @@ -27,7 +37,7 @@ import { runGit } from "../git/env.ts"; | ||
| 27 | 37 | import { isSafeOid } from "../git/guard.ts"; |
| 28 | 38 | import { repoDir } from "../git/repos.ts"; |
| 29 | 39 | import { noRevertWhy, pinsLandedBy } from "./pinned_landing.ts"; |
| 30 | import { everReverted } from "./revert_red.ts"; | |
| 40 | import { everReverted, FORGE_CLOSED } from "./revert_red.ts"; | |
| 31 | 41 | import { |
| 32 | 42 | BISECT_ENV, |
| 33 | 43 | BISECT_PREFIX, |
| @@ -72,6 +82,30 @@ function finishedBefore(app: App, repoId: string, below: string): Run | undefine | ||
| 72 | 82 | return row === null ? undefined : getRun(app.db, row.id); |
| 73 | 83 | } |
| 74 | 84 | |
| 85 | /** The finished verification just after run `above`, green or red. */ | |
| 86 | function finishedAfter(app: App, repoId: string, above: string): Run | undefined { | |
| 87 | const row = app.db | |
| 88 | .query<{ id: string }, [string, string]>( | |
| 89 | `SELECT id FROM run WHERE repo_id = ?1 AND kind = 'check' AND env = '${VERIFY_ENV}' | |
| 90 | AND state IN ('ok','failed') AND id > ?2 ORDER BY id LIMIT 1`, | |
| 91 | ) | |
| 92 | .get(repoId, above); | |
| 93 | return row === null ? undefined : getRun(app.db, row.id); | |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * Whether red run `later` fails a test red run `red` failed: a name both name, or a file when | |
| 98 | * either names none. | |
| 99 | */ | |
| 100 | function sameTest(red: Run, later: Run): boolean { | |
| 101 | if (later.state !== "failed") return false; | |
| 102 | const names = red.checkDetail?.names ?? []; | |
| 103 | const again = later.checkDetail?.names ?? []; | |
| 104 | if (names.length > 0 && again.length > 0) return names.some((n) => again.includes(n)); | |
| 105 | const files = later.checkDetail?.files ?? []; | |
| 106 | return (red.checkDetail?.files ?? []).some((f) => files.includes(f)); | |
| 107 | } | |
| 108 | ||
| 75 | 109 | /** What each finished step of `origin`'s bisection said, by commit: green or not. */ |
| 76 | 110 | function stepsOf(app: App, repoId: string, origin: string): { green: Map<string, boolean>; vague: Run | undefined } { |
| 77 | 111 | const rows = app.db |
| @@ -102,6 +136,36 @@ async function rangeOf(app: App, repo: Repo, green: string, red: string): Promis | ||
| 102 | 136 | return log.ok ? log.value.split("\n").filter(Boolean) : undefined; |
| 103 | 137 | } |
| 104 | 138 | |
| 139 | /** | |
| 140 | * The commit `red`'s finished bisection named, with the green it started from and its steps; | |
| 141 | * undefined while it is still walking, or when it named none. | |
| 142 | */ | |
| 143 | async function culpritOf(app: App, repo: Repo, red: Run): Promise<{ commit: string; green: string; tried: number } | undefined> { | |
| 144 | const green = greenBefore(app, repo.id, red.id); | |
| 145 | if (green === undefined) return undefined; | |
| 146 | const range = await rangeOf(app, repo, green.commitOid, red.commitOid); | |
| 147 | if (range === undefined || range.length === 0) return undefined; | |
| 148 | const window = range.length > MAX_RANGE ? range.slice(-MAX_RANGE) : range; | |
| 149 | const { green: tried, vague } = stepsOf(app, repo.id, red.id); | |
| 150 | if (vague !== undefined) return undefined; | |
| 151 | const step = nextStep(window, tried); | |
| 152 | if (step?.kind !== "culprit" || (window.length < range.length && step.commit === window[0])) return undefined; | |
| 153 | return { commit: step.commit, green: green.commitOid, tried: tried.size }; | |
| 154 | } | |
| 155 | ||
| 156 | /** | |
| 157 | * The red verification next to `red` that confirms `culprit`: the one just after it failing the | |
| 158 | * same test (red since the same green, so it holds the culprit and bisects to it), or the one just | |
| 159 | * before it, failing the same test, whose own bisection named the same commit. | |
| 160 | */ | |
| 161 | async function confirmingRed(app: App, repo: Repo, red: Run, culprit: string): Promise<Run | undefined> { | |
| 162 | const after = finishedAfter(app, repo.id, red.id); | |
| 163 | if (after !== undefined && sameTest(red, after)) return after; | |
| 164 | const before = finishedBefore(app, repo.id, red.id); | |
| 165 | if (before !== undefined && sameTest(before, red) && (await culpritOf(app, repo, before))?.commit === culprit) return before; | |
| 166 | return undefined; | |
| 167 | } | |
| 168 | ||
| 105 | 169 | /** The pull whose landing is `oid` on the default branch, if one is. */ |
| 106 | 170 | function landingOf(app: App, repo: Repo, oid: string): Pull | undefined { |
| 107 | 171 | const row = app.db |
| @@ -160,10 +224,14 @@ async function name(app: App, repo: Repo, red: Run, culprit: string, green: stri | ||
| 160 | 224 | `${FILED_BY}\n\n#${pull.number} (${short(culprit)}) broke ${redSays(red)} — ${how}. ` + |
| 161 | 225 | `${noRevertWhy(pins)}.\n\nFiles: ${files.join(", ")}`, |
| 162 | 226 | )}`; |
| 227 | const again = await confirmingRed(app, repo, red, culprit); | |
| 228 | if (again === undefined) | |
| 229 | return `culprit #${pull.number} (${short(culprit)}): its revert waits for the next verification to fail the same test`; | |
| 163 | 230 | const owner = getUserById(app.db, repo.ownerId); |
| 164 | 231 | const body = |
| 165 | 232 | `Reverts #${pull.number}: verifying main after landing found it broke ${redSays(red)} — ${how}.\n\n` + |
| 166 | `Main's verification ${red.id} is red at ${short(red.commitOid)}; each failed test fails alone too.\n\n` + | |
| 233 | `Main's verifications ${red.id} and ${again.id} are red at ${short(red.commitOid)} and ${short(again.commitOid)}, ` + | |
| 234 | `one after the other; each failed test fails alone too.\n\n` + | |
| 167 | 235 | `Proposed by the forge; a person lands it.\n\nFiles: ${files.join(", ")}`; |
| 168 | 236 | const made = await revertPull(app, owner, repo, pull, body); |
| 169 | 237 | return made.ok |
| @@ -202,8 +270,13 @@ export async function afterVerify(app: App, repo: Repo, run: Run, ask: Ask): Pro | ||
| 202 | 270 | if (run === red) { |
| 203 | 271 | const before = finishedBefore(app, repo.id, red.id); |
| 204 | 272 | const known = before?.state === "failed" ? (before.checkDetail?.files ?? []) : []; |
| 205 | if (known.length > 0 && files.every((f) => known.includes(f))) | |
| 206 | return [`not bisected: ${files.join(", ")} already failed at ${short(before!.commitOid)}, named there`]; | |
| 273 | if (known.length > 0 && files.every((f) => known.includes(f))) { | |
| 274 | const said = `not bisected: ${files.join(", ")} already failed at ${short(before!.commitOid)}, named there`; | |
| 275 | // The red before, failing the same test, may have named a culprit whose revert waits for this | |
| 276 | // one. | |
| 277 | const earlier = sameTest(before!, red) ? await culpritOf(app, repo, before!) : undefined; | |
| 278 | return earlier === undefined ? [said] : [said, await name(app, repo, before!, earlier.commit, earlier.green, earlier.tried)]; | |
| 279 | } | |
| 207 | 280 | } |
| 208 | 281 | const green = greenBefore(app, repo.id, red.id); |
| 209 | 282 | if (green === undefined) return [unbisected(app, repo, red, "main was never verified green before")]; |
| @@ -287,3 +360,49 @@ export function closeOnGreen(app: App, repo: Repo, run: Run, passed: readonly st | ||
| 287 | 360 | } |
| 288 | 361 | return lines; |
| 289 | 362 | } |
| 363 | ||
| 364 | /** How a revert this module proposed opens: the pull and what its verification found. */ | |
| 365 | const REVERT_SAYS = /^Reverts #\d+: verifying main after landing found it broke /; | |
| 366 | ||
| 367 | /** | |
| 368 | * The lines for a green verification's log: each open revert this module proposed before `run` was | |
| 369 | * asked for, whose every named file `run` printed passing while the pull it takes back is still on | |
| 370 | * main, closed with that reason in one line and its branch dropped. The red it answered was not | |
| 371 | * that pull's: main is green with it, and a later break of that pull may be reverted again | |
| 372 | * (`everReverted` skips a revert the forge closed). A revert a person has commented on stays open: | |
| 373 | * the comment is their say. The forge's own close comment is posted under the owner's name and says | |
| 374 | * so; it is written as the revert closes, so it never stands as a person's word on an open one. | |
| 375 | */ | |
| 376 | export async function closeRevertsOnGreen(app: App, repo: Repo, run: Run, passed: readonly string[]): Promise<string[]> { | |
| 377 | if (run.env !== VERIFY_ENV || run.state !== "ok" || passed.length === 0 || !isSafeOid(run.commitOid)) return []; | |
| 378 | const open = app.db | |
| 379 | .query<{ id: string; number: number; body: string; target: number; landed: string | null }, [string, string, string]>( | |
| 380 | `SELECT i.id, i.number, i.body, t.number AS target, tp.merged_oid AS landed | |
| 381 | FROM issue i JOIN pull p ON p.issue_id = i.id | |
| 382 | JOIN issue t ON t.id = p.reverts_issue_id JOIN pull tp ON tp.issue_id = t.id | |
| 383 | WHERE i.repo_id = ?1 AND i.kind = 'pull' AND i.state = 'open' AND p.merged_at IS NULL | |
| 384 | AND i.author_id = ?2 AND i.created_at < ?3 | |
| 385 | AND NOT EXISTS (SELECT 1 FROM comment JOIN user ON user.id = comment.author_id | |
| 386 | WHERE comment.issue_id = i.id AND user.is_agent = 0) | |
| 387 | ORDER BY i.number`, | |
| 388 | ) | |
| 389 | .all(repo.id, repo.ownerId, run.createdAt); | |
| 390 | const owner = getUserById(app.db, repo.ownerId); | |
| 391 | const dir = repoDir(app.reposRoot, repo.ownerName, repo.name); | |
| 392 | const lines: string[] = []; | |
| 393 | for (const r of open) { | |
| 394 | if (owner === undefined || !REVERT_SAYS.test(r.body) || r.landed === null || !isSafeOid(r.landed)) continue; | |
| 395 | const files = filesNamed(r.body); | |
| 396 | if (files.length === 0 || !files.every((f) => passed.includes(f))) continue; | |
| 397 | if (!(await runGit(["merge-base", "--is-ancestor", r.landed, run.commitOid], { cwd: dir })).ok) continue; | |
| 398 | const issue = getIssueById(app.db, r.id); | |
| 399 | if (issue === undefined) continue; | |
| 400 | const why = `${FORGE_CLOSED}verification ${run.id} is green at ${short(run.commitOid)} with #${r.target} still in it, so the red this revert answered was not #${r.target}'s. (The forge posts this under the owner's name; the owner did not write it.)`; | |
| 401 | commentAs(app, owner, repo, issue, why); | |
| 402 | if (!closeAs(app, owner, repo, issue, "closed").ok) continue; | |
| 403 | const pull = getPull(app.db, repo.id, r.number); | |
| 404 | if (pull !== undefined) await deleteBranch(app, owner, repo, pull.headBranch); | |
| 405 | lines.push(`culprit: closed revert #${r.number}, #${r.target} is green on main`); | |
| 406 | } | |
| 407 | return lines; | |
| 408 | } |
src/checks/execute.ts +3 −1
| @@ -7,7 +7,7 @@ import type { Repo } from "../core/repos.ts"; | ||
| 7 | 7 | import { cancelRun, getRun, claimRun, finishRun, overranBefore, vanishedBefore, VANISHED_SUMMARY, infraBefore, INFRA_SUMMARY, stalledBefore, STALLED_SUMMARY, CPU_STOP_SUMMARY, DISK_USED_SUMMARY, requeueCheck, chainCutOffs, CHECK_RELEASE_LIMIT, RELEASE_SUMMARY, type Run } from "../core/runs.ts"; |
| 8 | 8 | import { withDisk } from "./disk_red.ts"; |
| 9 | 9 | import { proposeRevert } from "./revert_red.ts"; |
| 10 | import { afterVerify, closeOnGreen } from "./culprit.ts"; | |
| 10 | import { afterVerify, closeOnGreen, closeRevertsOnGreen } from "./culprit.ts"; | |
| 11 | 11 | import { noteLookPages } from "./look_pages.ts"; |
| 12 | 12 | import { reportGreen, reportRed, type AloneAnswer } from "./report.ts"; |
| 13 | 13 | import type { Database } from "bun:sqlite"; |
| @@ -242,6 +242,8 @@ export async function execute( | ||
| 242 | 242 | reportGreen(app, repo, done, outcome.passed ?? []).forEach(write); |
| 243 | 243 | // A green that ran every file a culprit's issue names closes it (#11395). |
| 244 | 244 | closeOnGreen(app, repo, done, outcome.passed ?? []).forEach(write); |
| 245 | // ...and a revert it proposed, its target still on main, closes with the reason. | |
| 246 | (await closeRevertsOnGreen(app, repo, done, outcome.passed ?? [])).forEach(write); | |
| 245 | 247 | } |
| 246 | 248 | if (done && inVerifyLane(run.env)) |
| 247 | 249 | await afterVerify(app, repo, done, (r, env, oid, reason) => lane.request(r, env, oid, reason)) |
src/checks/revert_red.ts +18 −3
| @@ -36,12 +36,27 @@ function greenBefore(app: App, repoId: string, branch: string, below: string): s | ||
| 36 | 36 | .get(repoId, branch, below)?.commit_oid; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | /** Whether any pull, in any state, already takes `pullId` back. */ | |
| 39 | /** | |
| 40 | * How the forge's close of a revert it proposed opens, when a green showed the red was not its | |
| 41 | * target's (`culprit.ts`). | |
| 42 | */ | |
| 43 | export const FORGE_CLOSED = "Closed by the forge: main's "; | |
| 44 | ||
| 45 | /** | |
| 46 | * Whether a pull already takes `pullId` back: open, landed, or closed by a person. A revert the | |
| 47 | * forge closed itself on a green (`FORGE_CLOSED`) does not count: that red was not this pull's, so | |
| 48 | * a later break that is can be reverted. | |
| 49 | */ | |
| 40 | 50 | export function everReverted(app: App, pullId: string): boolean { |
| 41 | 51 | return ( |
| 42 | 52 | app.db |
| 43 | .query<{ n: number }, [string]>("SELECT COUNT(*) AS n FROM pull WHERE reverts_issue_id = ?1") | |
| 44 | .get(pullId)!.n > 0 | |
| 53 | .query<{ n: number }, [string, string]>( | |
| 54 | `SELECT COUNT(*) AS n FROM pull p JOIN issue i ON i.id = p.issue_id | |
| 55 | WHERE p.reverts_issue_id = ?1 | |
| 56 | AND NOT (i.state = 'closed' AND p.merged_at IS NULL | |
| 57 | AND EXISTS (SELECT 1 FROM comment c WHERE c.issue_id = i.id AND substr(c.body, 1, length(?2)) = ?2))`, | |
| 58 | ) | |
| 59 | .get(pullId, FORGE_CLOSED)!.n > 0 | |
| 45 | 60 | ); |
| 46 | 61 | } |
| 47 | 62 |
test/verify-after-landing.test.ts +92 −7
| @@ -14,7 +14,9 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 14 | 14 | import { mergePull, openPull } from "../src/actions/pulls.ts"; |
| 15 | 15 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 16 | 16 | import { parseCheck } from "../src/apps/manifest.ts"; |
| 17 | import { afterVerify } from "../src/checks/culprit.ts"; | |
| 17 | import { afterVerify, closeRevertsOnGreen } from "../src/checks/culprit.ts"; | |
| 18 | import { everReverted } from "../src/checks/revert_red.ts"; | |
| 19 | import { revertPull } from "../src/actions/revert.ts"; | |
| 18 | 20 | import { |
| 19 | 21 | BISECT_ENV, |
| 20 | 22 | BISECT_PREFIX, |
| @@ -230,7 +232,9 @@ describe("a red verification names its culprit", () => { | ||
| 230 | 232 | await rm(dataDir, { recursive: true, force: true }); |
| 231 | 233 | }); |
| 232 | 234 | |
| 233 | test("four landings since the green: the third is named in two steps, and its revert is proposed once", async () => { | |
| 235 | const reverts = () => listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null); | |
| 236 | ||
| 237 | test("four landings since the green: the third is named in two steps, and its revert waits for a second red", async () => { | |
| 234 | 238 | await verification("ok"); |
| 235 | 239 | const pulls: Pull[] = []; |
| 236 | 240 | const oids: string[] = []; |
| @@ -242,16 +246,97 @@ describe("a red verification names its culprit", () => { | ||
| 242 | 246 | const { lines, steps } = await bisect(red, oids[2]!, oids); |
| 243 | 247 | expect(steps).toBeLessThanOrEqual(maxSteps(4)); |
| 244 | 248 | expect(lines.at(-1)).toContain(`culprit #${pulls[2]!.number}`); |
| 245 | const reverts = listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null); | |
| 246 | expect(reverts.map((p) => p.revertsPullId)).toEqual([pulls[2]!.id]); | |
| 247 | expect(reverts[0]!.body).toContain(FILE); | |
| 248 | expect(reverts[0]!.body).toContain("thing > works"); | |
| 249 | expect(reverts[0]!.mergedAt).toBeNull(); | |
| 249 | expect(lines.at(-1)).toContain("waits for the next verification to fail the same test"); | |
| 250 | expect(reverts()).toHaveLength(0); | |
| 251 | // The next verification fails the same test: now the revert is proposed, once. | |
| 252 | const again = await verification("failed"); | |
| 253 | const confirmed = await afterVerify(app, repo, again, async () => undefined); | |
| 254 | expect(confirmed.at(-1)).toContain(`proposed its revert`); | |
| 255 | const proposed = reverts(); | |
| 256 | expect(proposed.map((p) => p.revertsPullId)).toEqual([pulls[2]!.id]); | |
| 257 | expect(proposed[0]!.body).toContain(FILE); | |
| 258 | expect(proposed[0]!.body).toContain("thing > works"); | |
| 259 | expect(proposed[0]!.mergedAt).toBeNull(); | |
| 260 | expect(proposed[0]!.body).toContain(`${red.id} and ${again.id}`); | |
| 250 | 261 | // The same red asked again proposes nothing more. |
| 251 | 262 | expect((await afterVerify(app, repo, red, async () => undefined))[0]).toContain("already proposed"); |
| 252 | 263 | expect(listPulls(app.db, repo.id, { state: "all" }).filter((p) => p.revertsPullId !== null)).toHaveLength(1); |
| 253 | 264 | }); |
| 254 | 265 | |
| 266 | test("a red the next verification does not repeat proposes no revert", async () => { | |
| 267 | await verification("ok"); | |
| 268 | const one = await land("one"); | |
| 269 | const red = await verification("failed"); | |
| 270 | expect((await afterVerify(app, repo, red, async () => undefined))[0]).toContain(`culprit #${one.number}`); | |
| 271 | await verification("ok"); | |
| 272 | // Asked again after the green, the red still has no second red beside it. | |
| 273 | expect((await afterVerify(app, repo, red, async () => undefined))[0]).toContain("waits for the next verification"); | |
| 274 | expect(reverts()).toHaveLength(0); | |
| 275 | }); | |
| 276 | ||
| 277 | test("a second red that came while the first was still bisecting confirms it when the bisection ends", async () => { | |
| 278 | await verification("ok"); | |
| 279 | const pulls = [await land("one"), await land("two")]; | |
| 280 | const red = await verification("failed"); | |
| 281 | let asked: Run | undefined; | |
| 282 | const lines = await afterVerify(app, repo, red, async (_r, env, commitOid, reason) => (asked = createRun(app.db, { repoId: repo.id, kind: "check", env, commitOid, reason }))); | |
| 283 | expect(lines[0]).toContain("bisect: trying"); | |
| 284 | // The next verification is red with the same test before the step finishes: nothing to confirm | |
| 285 | // yet. | |
| 286 | const again = await verification("failed"); | |
| 287 | expect(await afterVerify(app, repo, again, async () => undefined)).toEqual([expect.stringContaining("not bisected")]); | |
| 288 | expect(reverts()).toHaveLength(0); | |
| 289 | // The step is green at the first landing: the second is the culprit, and the red after confirms | |
| 290 | // it. | |
| 291 | const done = finish(asked!, "ok"); | |
| 292 | const named = await afterVerify(app, repo, done, async () => undefined); | |
| 293 | expect(named.at(-1)).toContain(`culprit #${pulls[1]!.number}`); | |
| 294 | expect(named.at(-1)).toContain("proposed its revert"); | |
| 295 | expect(reverts().map((p) => p.revertsPullId)).toEqual([pulls[1]!.id]); | |
| 296 | }); | |
| 297 | ||
| 298 | test("a green verification with the target still on main closes the forge's revert, saying why; a person's word keeps one", async () => { | |
| 299 | await verification("ok"); | |
| 300 | const one = await land("one"); | |
| 301 | const red = await verification("failed"); | |
| 302 | await afterVerify(app, repo, red, async () => undefined); | |
| 303 | await afterVerify(app, repo, await verification("failed"), async () => undefined); | |
| 304 | const [revert] = reverts(); | |
| 305 | expect(revert?.state).toBe("open"); | |
| 306 | // A green that did not run the named file closes nothing. | |
| 307 | const partial = await verification("ok"); | |
| 308 | expect(await closeRevertsOnGreen(app, repo, partial, ["test/other.test.ts"])).toEqual([]); | |
| 309 | const green = await verification("ok"); | |
| 310 | const lines = await closeRevertsOnGreen(app, repo, green, [FILE]); | |
| 311 | expect(lines).toEqual([`culprit: closed revert #${revert!.number}, #${one.number} is green on main`]); | |
| 312 | expect(getPull(app.db, repo.id, revert!.number)?.state).toBe("closed"); | |
| 313 | const said = app.db.query<{ body: string }, [string]>("SELECT body FROM comment WHERE issue_id = ?1").all(revert!.id); | |
| 314 | expect(said.map((c) => c.body)).toEqual([expect.stringContaining(`with #${one.number} still in it`)]); | |
| 315 | expect(said[0]!.body).toContain("the owner did not write it"); | |
| 316 | // Asked again, nothing more is said. | |
| 317 | expect(await closeRevertsOnGreen(app, repo, await verification("ok"), [FILE])).toEqual([]); | |
| 318 | // The revert the forge closed blocks nothing: its branch is gone and the pull may be reverted | |
| 319 | // again when it really breaks main. | |
| 320 | expect(await resolveOid(repoDir(app.reposRoot, repo.ownerName, repo.name), `refs/heads/${revert!.headBranch}`)).toBeUndefined(); | |
| 321 | expect(everReverted(app, one.id)).toBe(false); | |
| 322 | const again = await revertPull(app, alice, repo, one); | |
| 323 | expect(again.ok).toBe(true); | |
| 324 | // One a person closed still counts: that was their word. | |
| 325 | if (again.ok) app.db.query("UPDATE issue SET state = 'closed' WHERE id = ?1").run(again.value.id); | |
| 326 | expect(everReverted(app, one.id)).toBe(true); | |
| 327 | }); | |
| 328 | ||
| 329 | test("a revert a person commented on stays open on green", async () => { | |
| 330 | await verification("ok"); | |
| 331 | await land("one"); | |
| 332 | await afterVerify(app, repo, await verification("failed"), async () => undefined); | |
| 333 | await afterVerify(app, repo, await verification("failed"), async () => undefined); | |
| 334 | const [revert] = reverts(); | |
| 335 | app.db.query("INSERT INTO comment (id, issue_id, author_id, body) VALUES ('c-person', ?1, ?2, 'keep this')").run(revert!.id, alice.id); | |
| 336 | expect(await closeRevertsOnGreen(app, repo, await verification("ok"), [FILE])).toEqual([]); | |
| 337 | expect(getPull(app.db, repo.id, revert!.number)?.state).toBe("open"); | |
| 338 | }); | |
| 339 | ||
| 255 | 340 | test("a culprit that added a migration pin is named in one issue, not a revert the gate refuses (#16637)", async () => { |
| 256 | 341 | await verification("ok"); |
| 257 | 342 | const pin = "src/core/migration-pins/20261128100000-walks.pin"; |
new above
offline