diff --git a/scripts/dispatch-issue-triage.test.ts b/scripts/dispatch-issue-triage.test.ts index 6bfbe1bb514..15d879b2017 100644 --- a/scripts/dispatch-issue-triage.test.ts +++ b/scripts/dispatch-issue-triage.test.ts @@ -72,6 +72,13 @@ describe("dispatchTarget", () => { expect(dispatchTarget(ready(), [unrelated], [])).toEqual({ kind: "dispatch" }); }); + test("only the workflow's own marker counts, a commenter pasting it cannot opt the issue out", () => { + const forged: Comment = { ...marker, user: { type: "User", login: "someone" } }; + expect(dispatchTarget(ready(), [forged], [])).toEqual({ kind: "dispatch" }); + const otherBot: Comment = { ...marker, user: { type: "Bot", login: "some-other-app[bot]" } }; + expect(dispatchTarget(ready(), [otherBot], [])).toEqual({ kind: "dispatch" }); + }); + test("an open pull request that references the issue blocks, a merged one or a plain issue does not", () => { expect(reasonOf(dispatchTarget(ready(), [], [crossRef(41950, "open")]))).toBe("open pull request #41950 already references it"); expect(reasonOf(dispatchTarget(ready(), [], [crossRef(41950, "open"), crossRef(41960, "open")]))).toBe( diff --git a/scripts/dispatch-issue-triage.ts b/scripts/dispatch-issue-triage.ts index a48f28dd5ba..caeb1de1134 100644 --- a/scripts/dispatch-issue-triage.ts +++ b/scripts/dispatch-issue-triage.ts @@ -31,6 +31,7 @@ export type DispatchVerdict = export const BUG_LABEL = labelName("kind", "bug"); export const RUNNING_LABEL = labelName("repro", "running"); export const DISPATCH_MARKER = ""; +export const DISPATCH_AUTHOR = "github-actions[bot]"; export const DISPATCH_COMMENT = [ DISPATCH_MARKER, "Devin is going to try to reproduce this. A PR or a Linear ticket follows if it does. Add repro:skip to opt out", @@ -70,7 +71,7 @@ export function dispatchTarget( if (blocking.length > 0) { return skip(`carries ${blocking.join(", ")}`); } - if (comments.some((comment) => comment.body.includes(DISPATCH_MARKER))) { + if (comments.some((comment) => comment.user.login === DISPATCH_AUTHOR && comment.body.includes(DISPATCH_MARKER))) { return skip("was already dispatched once"); } const pulls = openPullsReferencing(timeline); diff --git a/scripts/flag-duplicate-issue.test.ts b/scripts/flag-duplicate-issue.test.ts index 81d2b135366..ec646d8f8f5 100644 --- a/scripts/flag-duplicate-issue.test.ts +++ b/scripts/flag-duplicate-issue.test.ts @@ -195,6 +195,13 @@ describe("flagIssue", () => { const { api, writes } = fakeApi(undefined, [existing]); expect(await flagIssue(api, config, verdict())).toEqual({ kind: "skip", reason: "already carries a duplicate notice" }); expect(writes).toEqual([]); + + const rerun = fakeApi(undefined, [existing]); + expect(await flagIssue(rerun.api, config, verdict({ duplicate_of: null }))).toEqual({ + kind: "skip", + reason: "already carries a duplicate notice", + }); + expect(rerun.writes).toEqual([]); }); test("a failed comment leaves no marker, so the rerun finishes the job", async () => { diff --git a/scripts/flag-duplicate-issue.ts b/scripts/flag-duplicate-issue.ts index b28050892d1..f43ac24e57d 100644 --- a/scripts/flag-duplicate-issue.ts +++ b/scripts/flag-duplicate-issue.ts @@ -103,16 +103,16 @@ export function noticeBody(issue: Issue, prior: Issue, evidence: string): string export async function flagIssue(api: GitHubApi, config: FlagConfig, verdict: Verdict): Promise { const target = flagTarget(verdict, config.issueNumber); const issuePath = `/repos/${config.repo}/issues/${config.issueNumber}`; + const comments = await listAll(api, `${issuePath}/comments`); + if (comments.some((comment) => comment.body.includes(NOTICE_MARKER_PREFIX))) { + return skip("already carries a duplicate notice"); + } if (target.kind === "clear") { if (!config.dryRun) { await api.request("POST", `${issuePath}/labels`, { labels: [CLEAR_LABEL] }); } return target; } - const comments = await listAll(api, `${issuePath}/comments`); - if (comments.some((comment) => comment.body.includes(NOTICE_MARKER_PREFIX))) { - return skip("already carries a duplicate notice"); - } const prior = await api.request("GET", `/repos/${config.repo}/issues/${target.original}`); if (prior.pull_request !== undefined) { return skip(`#${target.original} is a pull request`);