Skip to content

Commit 747e009

Browse files
authored
fix(gate): a stop request dequeues a queued entry (#3280) (#3285)
Written-by: Dev Fixes #3280 Owner: Dev Reviewer: Reviewer # A stop request takes the entry out of the queue On #3279 the queue entry's required checks had all passed before the author's stop request existed, so neither `merge-gate` nor `enqueue-guard` could read it. This adds the missing reader. ## The window, as it happened (#3279, 2026-11-21) | UTC | event | | --- | --- | | 04:47:33Z | `Test` green at the tip — every check the queue reads has now run | | 04:47:43Z | the author comments `Stop request for this tip: …` | | 04:47:58Z | the queue merges the entry; nothing read the request | After: the comment takes the entry out of the queue through `dequeuePullRequest`, and the pull request stays open at its head. ## What changed - `.github/scripts/stop-request.mjs` — `parseStopRequest` reads `Stop request for this tip: <sha>` (case-insensitive, across lines, backticks allowed); `sameSha` accepts a 12+ character short sha either way; `dequeue` calls GraphQL `dequeuePullRequest` for the pull request node and returns `skipped` on 404/422 or when the head moved; `handleStopRequest` is the one decision, with the GraphQL client injected so the tests are offline. - `.github/workflows/stop-request.yml` — `issue_comment` `created`, pull requests only, code taken from `main`; `stop-request.mjs` drops anything that is not the marker, another tip, a merged pull request or a base other than `main`. On success it leaves `Dequeued by: Chief` with the tip and a link to the stop comment. - `.github/scripts/stop-request.test.mjs` — 10 tests, written first and run red against a missing module. - `docs/testing-layers.json`/`.md` — the new workflow's row in the manifest and the regenerated table. ## Verification Reproduce: a queue entry whose required checks are all green, then `Stop request for this tip: <sha>` on the pull request. Before, the queue merges it 15 s later; after, the entry is dequeued. Ran at this tip: ```sh $ cd .github/scripts && TZ=UTC node --test stop-request.test.mjs # tests 10 # pass 10 # fail 0 $ cd .github/scripts && TZ=UTC node --test enqueue-guard.test.mjs merge-gate.test.mjs # tests 207 # pass 207 # fail 0 $ node .github/scripts/testing-layers.mjs --check # 37 test file(s) in 18 workflow(s); every test file and every workflow is classified $ node -e 'YAML.parse(readFileSync(".github/workflows/stop-request.yml","utf8"))' # issue_comment: {types: [created]}; yaml@2.9.1, syntax only ``` All four ran at `b27e1ffab8a1800c4fa2667c4274f2d6bc5c41e7`; the five files in this commit are byte for byte the ones those runs read (blob sha compared). ### Revert check (red) With `.github/scripts/stop-request.mjs` replaced by a no-op stub (`parseStopRequest` → null, `sameSha` → false, `dequeue` → `skipped`, `handleStopRequest` → `{action:'none'}`) the same command goes red: 6 of 10 fail, exit 1. - not ok 1 — parseStopRequest reads the tip request, its short sha and backticks, and nothing else - not ok 2 — sameSha accepts a 12-character short sha either way and refuses another tip - not ok 3 — dequeue takes the entry out through dequeuePullRequest at the tip it read - not ok 6 — a stop request naming the live tip is dequeued and leaves `Dequeued by: Chief` - not ok 7 — a stop request naming another tip changes nothing - not ok 9 — only a pull request based on main is read, and a merged one is never re-judged The 4 that stay green are the assertions that nothing happens (a non-stop comment, a plain issue) and the two skip branches the stub answers with the same value. The implementation was restored (blob sha matches the tip) and both commands re-ran green. ### Not run - `npm run verify` and the core/plugins suites: this host has no full checkout and no `core/node_modules` (only api.github.com is reachable, github.com is not). The full `.github/scripts/*.test.mjs` suite was run instead: 673 pass, 21 fail, every failure from files the partial checkout does not have (`core/`, `plugins/`, `CHANGELOG.md`, `docs/images/`) — none names `stop-request`. CI's `package` job, which does have the checkout, ran them green. - `actionlint` is not installed here; the workflow was parsed with the `yaml` package. - The real `dequeuePullRequest` call is not exercised locally: the GraphQL client is injected in the tests and only a live stop-request comment will use it. Docs-not-needed: .github scripts and workflows own no subsystem page; the test-layer manifest and its generated doc are updated in this commit. ## Checkpoint <!-- flybot:checkpoint --> { "pr": 3285, "claim": "Dev", "issue": 3280, "summary": "A stop request posted after a queued entry's required checks have run now takes that entry out of the merge queue. A new issue_comment workflow reads 'Stop request for this tip: <sha>', confirms the sha is still the live head of a pull request based on main, and calls GitHub's dequeuePullRequest. It leaves one note naming the tip and linking the request. The GraphQL client is injected, so the tests run offline.", "files": [".github/scripts/stop-request.mjs",".github/scripts/stop-request.test.mjs",".github/workflows/stop-request.yml","docs/testing-layers.json","docs/testing-layers.md"], "checks": { "ran": "node --test stop-request.test.mjs; node --test enqueue-guard.test.mjs merge-gate.test.mjs; testing-layers.mjs --check", "result": "green", "at": "b27e1ffab8a1800c4fa2667c4274f2d6bc5c41e7" }, "next": "none — ready for review" } <!-- /flybot:checkpoint -->
1 parent 041342a commit 747e009

5 files changed

Lines changed: 429 additions & 0 deletions

File tree

‎.github/scripts/stop-request.mjs‎

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
// The stop-request dequeue (#3280). `merge-gate` and `enqueue-guard` both read a stop request — but both
2+
// have already run when one arrives after the required checks: on #3279 `Test` went green at 04:47:33Z,
3+
// the author's "Stop request for this tip: do not merge `8bbd01ba…`" landed at 04:47:43Z, and the queue
4+
// merged the entry at 04:47:58Z. The 25 s in between belong to no check, so nothing could refuse. This
5+
// module closes that window from the other side: an `issue_comment` event whose body names the live tip
6+
// takes the queued entry out through GitHub's `dequeuePullRequest`, and the pull request stays open at
7+
// that head.
8+
//
9+
// It is not a second verdict reader, deliberately. The two gates decide whether the tip may merge; this
10+
// only answers "does a person ask not to merge this exact tip, and is it still queued" — the sentence is
11+
// the marker `Stop request for this tip: <sha>`, so a hold with no sha, a request naming an older tip
12+
// and a merged pull request all change nothing. `enqueue-guard.mjs`/`enqueue-rules.mjs` carry the
13+
// "do not merge" vocabulary but no sha marker (their stop request names no tip), so there is one
14+
// implementation of this marker and it lives here; the other module is imported by nobody and edited by
15+
// nobody from here.
16+
import { readFileSync } from 'node:fs'
17+
import { fileURLToPath } from 'node:url'
18+
19+
const SHORT = 12
20+
const STOP_MARKER = /stop\s+request\s+for\s+this\s+tip\b/i
21+
// A sha is the run of hex characters nobody longer; the lookarounds keep a 12-character prefix inside a
22+
// longer word from being read as a tip. Parsing accepts 7 (the shortest GitHub shows), `sameSha` is what
23+
// insists on 12 — a tip a person can name unambiguously.
24+
const SHA = /(?<![0-9a-f])[0-9a-f]{7,40}(?![0-9a-f])/i
25+
const ALREADY_OUT = /not (?:in|currently in) the (?:merge )?queue|not currently queued|no longer in the queue|already been merged|already merged/i
26+
27+
export function parseStopRequest(body) {
28+
const text = String(body ?? '')
29+
const marker = STOP_MARKER.exec(text)
30+
if (!marker) return null
31+
const rest = text.slice(marker.index + marker[0].length)
32+
const sha = SHA.exec(rest)
33+
return sha ? { sha: sha[0].toLowerCase() } : null
34+
}
35+
36+
// A short sha names a tip only when it is long enough to be one on its own, and either side may be the
37+
// short form: a person writes 12 characters, the REST/GraphQL API returns 40.
38+
export function sameSha(a, b) {
39+
const x = String(a ?? '').toLowerCase()
40+
const y = String(b ?? '').toLowerCase()
41+
if (!/^[0-9a-f]+$/.test(x) || !/^[0-9a-f]+$/.test(y)) return false
42+
if (x.length < SHORT || y.length < SHORT) return false
43+
return x.startsWith(y) || y.startsWith(x)
44+
}
45+
46+
const GITHUB_GRAPHQL = 'https://api.github.com/graphql'
47+
48+
// The injectable client: the tests hand in a fake, the CLI builds this one. A GraphQL refusal arrives as
49+
// HTTP 200 with an `errors` array, so the status alone cannot tell "already out of the queue" from a real
50+
// failure — `message` is what `dequeue` reads.
51+
export function graphqlClient(token, endpoint = GITHUB_GRAPHQL) {
52+
return async function graphql(query, variables = {}) {
53+
const response = await fetch(endpoint, {
54+
method: 'POST',
55+
headers: {
56+
Authorization: `bearer ${token}`,
57+
'Content-Type': 'application/json',
58+
'User-Agent': 'flybot-stop-request',
59+
},
60+
body: JSON.stringify({ query, variables }),
61+
})
62+
const text = await response.text()
63+
if (response.status === 404 || response.status === 422) {
64+
throw Object.assign(new Error(`GraphQL HTTP ${response.status}: ${text.slice(0, 300)}`), { status: response.status })
65+
}
66+
if (!response.ok) throw new Error(`GraphQL HTTP ${response.status}: ${text.slice(0, 300)}`)
67+
let payload = null
68+
try { payload = JSON.parse(text) } catch { /* the status above already refused a bad body */ }
69+
if (payload?.errors?.length) {
70+
throw Object.assign(new Error(payload.errors.map((error) => error.message).join('; ')), { status: response.status })
71+
}
72+
return payload?.data
73+
}
74+
}
75+
76+
const PULL_QUERY = `query($owner: String!, $name: String!, $number: Int!) {
77+
repository(owner: $owner, name: $name) {
78+
pullRequest(number: $number) { id number headRefOid baseRefName merged state }
79+
}
80+
}`
81+
82+
const DEQUEUE_MUTATION = `mutation($id: ID!) {
83+
dequeuePullRequest(input: { id: $id }) { pullRequest { number headRefOid } }
84+
}`
85+
86+
async function readPull(graphql, repo, number) {
87+
const [owner, name] = String(repo ?? '').split('/')
88+
if (!owner || !name) throw new Error('set GITHUB_REPOSITORY or pass repo owner/name')
89+
const data = await graphql(PULL_QUERY, { owner, name, number: Number(number) })
90+
return data?.repository?.pullRequest ?? null
91+
}
92+
93+
// Take the entry out, but only while the tip is still the one the caller judged: the head is read again
94+
// here, so a push in the middle of `handleStopRequest` cannot dequeue a different commit than the one the
95+
// stop request named. An entry that is already out (404/422, or the queue's own "not in the queue"
96+
// refusal) is `skipped`, not an error: two comments in a row race the same queue and neither is a defect.
97+
export async function dequeue(prNumber, expectedHeadOid, { graphql = graphqlClient(process.env.GITHUB_TOKEN), repo = process.env.GITHUB_REPOSITORY, pull = null } = {}) {
98+
const target = pull ?? await readPull(graphql, repo, prNumber)
99+
if (!target?.id) return 'skipped'
100+
if (!sameSha(expectedHeadOid, target.headRefOid)) return 'skipped'
101+
try {
102+
await graphql(DEQUEUE_MUTATION, { id: target.id })
103+
return true
104+
} catch (error) {
105+
if (error?.status === 404 || error?.status === 422 || ALREADY_OUT.test(String(error?.message ?? ''))) return 'skipped'
106+
throw error
107+
}
108+
}
109+
110+
// The note the dequeue leaves on the pull request. `Dequeued by: Chief` is the line an operator looks for;
111+
// the tip and the stop comment make the record checkable without a second API read.
112+
export function dequeueNote({ head, stop }) {
113+
const link = stop?.html_url ? `\n\nStop request: ${stop.html_url}` : ''
114+
return [
115+
'Written-by: Chief',
116+
'',
117+
'Dequeued by: Chief',
118+
'',
119+
`The merge-queue entry at \`${head}\` was taken out of the queue after a stop request. The pull request stays open at this head.${link}`,
120+
].join('\n')
121+
}
122+
123+
async function commentOnPull({ prNumber, repo, body, token = process.env.GITHUB_TOKEN }) {
124+
const [owner, name] = String(repo ?? '').split('/')
125+
const response = await fetch(`https://api.github.com/repos/${owner}/${name}/issues/${prNumber}/comments`, {
126+
method: 'POST',
127+
headers: {
128+
Authorization: `Bearer ${token}`,
129+
Accept: 'application/vnd.github+json',
130+
'X-GitHub-Api-Version': '2022-11-28',
131+
'Content-Type': 'application/json',
132+
'User-Agent': 'flybot-stop-request',
133+
},
134+
body: JSON.stringify({ body }),
135+
})
136+
if (!response.ok) throw new Error(`could not comment on #${prNumber}: HTTP ${response.status} ${(await response.text()).slice(0, 300)}`)
137+
return response.json()
138+
}
139+
140+
// One `issue_comment` event in, one outcome out. Nothing is written for a body that is not the marker, and
141+
// the live head is compared before the queue is touched, so the one GraphQL route this module owns is
142+
// reached only for a stop request that names the tip the pull request is at.
143+
export async function handleStopRequest({ event, graphql = graphqlClient(process.env.GITHUB_TOKEN), repo = process.env.GITHUB_REPOSITORY, dequeue: dequeueImpl = dequeue, postComment = commentOnPull } = {}) {
144+
const issue = event?.issue
145+
const comment = event?.comment
146+
const parsed = parseStopRequest(comment?.body)
147+
if (!parsed) return { action: 'none', reason: 'not a stop request for a tip' }
148+
if (!issue?.pull_request) return { action: 'none', reason: 'a comment on an issue, not a pull request' }
149+
const prNumber = Number(issue.number)
150+
if (!Number.isInteger(prNumber) || prNumber <= 0) return { action: 'none', reason: 'no pull request number' }
151+
152+
const pull = await readPull(graphql, repo, prNumber)
153+
if (!pull) return { action: 'skipped', reason: 'the pull request is gone', parsed }
154+
if (pull.merged) return { action: 'ignored', reason: 'already merged', parsed, pull }
155+
if (String(pull.baseRefName) !== 'main') return { action: 'ignored', reason: `base is ${pull.baseRefName}, not main`, parsed, pull }
156+
if (!sameSha(parsed.sha, pull.headRefOid)) return { action: 'ignored', reason: 'the request names another tip', parsed, head: pull.headRefOid, pull }
157+
158+
const outcome = await dequeueImpl(prNumber, pull.headRefOid, { graphql, repo })
159+
if (outcome !== true) return { action: 'skipped', reason: 'the entry is no longer in the queue', parsed, head: pull.headRefOid, pull }
160+
161+
const body = dequeueNote({ head: pull.headRefOid, stop: comment })
162+
await postComment({ prNumber, repo, body })
163+
return { action: 'dequeued', parsed, head: pull.headRefOid, expectedHeadOid: pull.headRefOid, body, pull }
164+
}
165+
166+
export async function main({ eventPath = process.env.GITHUB_EVENT_PATH, env = process.env } = {}) {
167+
const event = JSON.parse(readFileSync(eventPath, 'utf8'))
168+
const result = await handleStopRequest({
169+
event,
170+
repo: env.GITHUB_REPOSITORY,
171+
graphql: graphqlClient(env.GITHUB_TOKEN),
172+
})
173+
const at = result.head ? ` at ${result.head}` : ''
174+
console.log(`stop-request: ${result.action}${result.reason ? ` — ${result.reason}` : ''}${at}`)
175+
return result
176+
}
177+
178+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
179+
main().catch((error) => {
180+
console.error(`stop-request: ${error.message}`)
181+
process.exit(1)
182+
})
183+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// The stop-request dequeue (#3280). A stop request that arrives after a queue entry's required checks
2+
// have run and before the queue merges it is read by no check: on #3279 `Test` went green at 04:47:33Z,
3+
// the author's request landed at 04:47:43Z, and the queue merged at 04:47:58Z. These tests pin the one
4+
// decision that closes that window — dequeue the entry, and only when the request names the live tip —
5+
// and they pin it offline: the GraphQL client is injected, so no test touches GitHub.
6+
import { test } from 'node:test'
7+
import assert from 'node:assert/strict'
8+
import { dequeue, handleStopRequest, parseStopRequest, sameSha } from './stop-request.mjs'
9+
10+
const TIP = '202fcc6711ac1e8af0877a7ab6865f05088487ae'
11+
const OTHER = '8bbd01baeefa413a7dfbb4accc5f9d5ddf46f6fa'
12+
const STOP_URL = 'https://github.com/ThinkFlowLab/FlyBot/pull/3280#issuecomment-7057486591'
13+
14+
const pull = (over = {}) => ({
15+
id: 'PR_kwDOA-node-3280',
16+
number: 3280,
17+
headRefOid: TIP,
18+
baseRefName: 'main',
19+
merged: false,
20+
state: 'OPEN',
21+
...over,
22+
})
23+
24+
const comment = (over = {}) => ({
25+
id: 7057486591,
26+
body: `Stop request for this tip: do not merge \`${TIP}\``,
27+
html_url: STOP_URL,
28+
user: { login: 'HugoXK', type: 'User' },
29+
...over,
30+
})
31+
32+
const event = (over = {}) => ({
33+
action: 'created',
34+
issue: { number: 3280, pull_request: { url: 'https://api.github.com/repos/ThinkFlowLab/FlyBot/pulls/3280' } },
35+
comment: comment(),
36+
...over,
37+
})
38+
39+
// A fake GraphQL client: it records every call, answers the pull-request read, and answers the dequeue
40+
// mutation — or throws the error a real entry outside the queue would produce.
41+
function fakeGraphql({ pr = pull(), dequeueError = null } = {}) {
42+
const calls = []
43+
const client = async (query, variables) => {
44+
calls.push({ query, variables })
45+
if (query.includes('dequeuePullRequest')) {
46+
if (dequeueError) throw dequeueError
47+
return { dequeuePullRequest: { pullRequest: { number: pr.number } } }
48+
}
49+
return { repository: { pullRequest: pr } }
50+
}
51+
return { client, calls, mutations: () => calls.filter((call) => call.query.includes('dequeuePullRequest')) }
52+
}
53+
54+
const graphqlError = (message, status) => Object.assign(new Error(message), { status })
55+
56+
test('#3280: parseStopRequest reads the tip request, its short sha and backticks, and nothing else', () => {
57+
assert.deepEqual(parseStopRequest(`Stop request for this tip: \`${TIP}\``), { sha: TIP })
58+
assert.deepEqual(parseStopRequest(`stop REQUEST for this tip: ${TIP.slice(0, 12)}`), { sha: TIP.slice(0, 12) })
59+
// The request usually carries a sentence between the marker and the sha, and the sha may sit on the
60+
// next line inside backticks — the shape #3279's comment used.
61+
assert.deepEqual(parseStopRequest(`Stop request for this tip: do not merge\n\`${TIP}\``), { sha: TIP })
62+
assert.equal(parseStopRequest('please do not merge this tip'), null, 'a hold without a tip is not this marker')
63+
assert.equal(parseStopRequest(`Stop request for this tip: nothing to name`), null, 'the marker names no sha')
64+
assert.equal(parseStopRequest(''), null)
65+
})
66+
67+
test('#3280: sameSha accepts a 12-character short sha either way and refuses another tip', () => {
68+
assert.equal(sameSha(TIP, TIP), true)
69+
assert.equal(sameSha(TIP, TIP.slice(0, 12)), true, 'a full sha matches the short form a person writes')
70+
assert.equal(sameSha(TIP.slice(0, 12), TIP), true, 'a short sha matches the full form the API returns')
71+
assert.equal(sameSha(TIP, OTHER), false)
72+
assert.equal(sameSha(TIP, TIP.slice(0, 7)), false, 'under 12 characters names no tip on its own')
73+
assert.equal(sameSha('', TIP), false)
74+
})
75+
76+
test('#3280: dequeue takes the entry out through dequeuePullRequest at the tip it read', async () => {
77+
const g = fakeGraphql()
78+
const out = await dequeue(3280, TIP, { graphql: g.client, repo: 'ThinkFlowLab/FlyBot' })
79+
80+
assert.equal(out, true)
81+
assert.equal(g.mutations().length, 1, 'one dequeuePullRequest mutation')
82+
assert.deepEqual(g.mutations()[0].variables, { id: 'PR_kwDOA-node-3280' }, 'the mutation names the pull request node id')
83+
})
84+
85+
test('#3280: dequeue is skipped, not failed, when the entry is no longer in the queue', async () => {
86+
for (const status of [404, 422]) {
87+
const g = fakeGraphql({ dequeueError: graphqlError('not in the queue', status) })
88+
assert.equal(await dequeue(3280, TIP, { graphql: g.client, repo: 'ThinkFlowLab/FlyBot' }), 'skipped', `HTTP ${status} means already out`)
89+
}
90+
// A GraphQL refusal arrives as a 200 body with an `errors` array; the message is what says "already out".
91+
const body = fakeGraphql({ dequeueError: graphqlError('Pull request #3280 is not in the merge queue', 200) })
92+
assert.equal(await dequeue(3280, TIP, { graphql: body.client, repo: 'ThinkFlowLab/FlyBot' }), 'skipped')
93+
})
94+
95+
test('#3280: dequeue never takes out an entry whose head already moved', async () => {
96+
const g = fakeGraphql({ pr: pull({ headRefOid: OTHER }) })
97+
assert.equal(await dequeue(3280, TIP, { graphql: g.client, repo: 'ThinkFlowLab/FlyBot' }), 'skipped')
98+
assert.equal(g.mutations().length, 0, 'the request names a tip that is no longer the head')
99+
})
100+
101+
test('#3280: a stop request naming the live tip is dequeued and leaves Dequeued by: Chief', async () => {
102+
const g = fakeGraphql()
103+
const seen = []
104+
const posted = []
105+
const r = await handleStopRequest({
106+
event: event({ comment: comment({ body: `Stop request for this tip: do not merge\n\`${TIP.slice(0, 12)}\`` }) }),
107+
graphql: g.client,
108+
repo: 'ThinkFlowLab/FlyBot',
109+
dequeue: async (prNumber, expectedHeadOid) => { seen.push([prNumber, expectedHeadOid]); return true },
110+
postComment: async (payload) => { posted.push(payload) },
111+
})
112+
113+
assert.equal(r.action, 'dequeued')
114+
assert.deepEqual(r.parsed, { sha: TIP.slice(0, 12) }, 'the short sha the person wrote is what the request parsed')
115+
assert.deepEqual(seen, [[3280, TIP]], 'dequeue got the pull request and the full live head it must still match')
116+
assert.equal(posted.length, 1)
117+
assert.match(posted[0].body, /Dequeued by: Chief/)
118+
assert.ok(posted[0].body.includes(TIP), 'the note names the tip')
119+
assert.ok(posted[0].body.includes(STOP_URL), 'the note links the stop request it answered')
120+
})
121+
122+
test('#3280: a stop request naming another tip changes nothing', async () => {
123+
const g = fakeGraphql()
124+
let called = false
125+
const r = await handleStopRequest({
126+
event: event({ comment: comment({ body: `Stop request for this tip: do not merge \`${OTHER}\`` }) }),
127+
graphql: g.client,
128+
repo: 'ThinkFlowLab/FlyBot',
129+
dequeue: async () => { called = true; return true },
130+
postComment: async () => {},
131+
})
132+
133+
assert.equal(r.action, 'ignored')
134+
assert.equal(called, false)
135+
assert.equal(g.mutations().length, 0)
136+
})
137+
138+
test('#3280: a comment that is not a stop request never calls GraphQL at all', async () => {
139+
const g = fakeGraphql()
140+
const r = await handleStopRequest({
141+
event: event({ comment: comment({ body: 'Looks good to me — thanks for the fix.' }) }),
142+
graphql: g.client,
143+
repo: 'ThinkFlowLab/FlyBot',
144+
dequeue: async () => assert.fail('no dequeue for a comment that names no tip'),
145+
postComment: async () => assert.fail('no note for a comment that names no tip'),
146+
})
147+
148+
assert.equal(r.action, 'none')
149+
assert.equal(g.calls.length, 0, 'not one request, so a stray stop request cannot touch the queue')
150+
})
151+
152+
test('#3280: only a pull request based on main is read, and a merged one is never re-judged', async () => {
153+
const notMain = fakeGraphql({ pr: pull({ baseRefName: 'release/v0.2.39' }) })
154+
const a = await handleStopRequest({
155+
event: event(),
156+
graphql: notMain.client,
157+
repo: 'ThinkFlowLab/FlyBot',
158+
dequeue: async () => assert.fail('a release branch has no main queue entry'),
159+
postComment: async () => {},
160+
})
161+
assert.equal(a.action, 'ignored')
162+
assert.match(a.reason, /not main/)
163+
164+
const merged = fakeGraphql({ pr: pull({ merged: true, state: 'MERGED' }) })
165+
const b = await handleStopRequest({
166+
event: event(),
167+
graphql: merged.client,
168+
repo: 'ThinkFlowLab/FlyBot',
169+
dequeue: async () => assert.fail('a merged pull request is history, not a request'),
170+
postComment: async () => {},
171+
})
172+
assert.equal(b.action, 'ignored')
173+
assert.match(b.reason, /merged/)
174+
})
175+
176+
test('#3280: a comment on a plain issue names no pull request and changes nothing', async () => {
177+
const g = fakeGraphql()
178+
const r = await handleStopRequest({
179+
event: { action: 'created', issue: { number: 12 }, comment: comment() },
180+
graphql: g.client,
181+
repo: 'ThinkFlowLab/FlyBot',
182+
dequeue: async () => assert.fail('an issue has no queue entry'),
183+
postComment: async () => {},
184+
})
185+
assert.equal(r.action, 'none')
186+
assert.equal(g.calls.length, 0)
187+
})

0 commit comments

Comments
 (0)