

















@@ -105,11 +105,16 @@ function barnacleIssueContext(
105105106106function barnacleGithub(
107107files: ReturnType<typeof file>[],
108-options: { maintainerLogins?: string[]; repositoryRoles?: Record<string, string> } = {},
108+options: {
109+maintainerLogins?: string[];
110+removeLabelNotFound?: string[];
111+repositoryRoles?: Record<string, string>;
112+} = {},
109113) {
110114const maintainerLogins = new Set(
111115(options.maintainerLogins ?? []).map((login) => login.toLowerCase()),
112116);
117+const removeLabelNotFound = new Set(options.removeLabelNotFound ?? []);
113118const repositoryRoles = Object.fromEntries(
114119Object.entries(options.repositoryRoles ?? {}).map(([login, role]) => [
115120login.toLowerCase(),
@@ -147,6 +152,11 @@ function barnacleGithub(
147152},
148153removeLabel: async (params: { issue_number: number; name: string }) => {
149154calls.removeLabel.push(params);
155+if (removeLabelNotFound.has(params.name)) {
156+const error = new Error("not found") as Error & { status: number };
157+error.status = 404;
158+throw error;
159+}
150160},
151161update: async (params: { issue_number: number; state?: string }) => {
152162calls.update.push(params);
@@ -516,6 +526,32 @@ describe("barnacle-auto-response", () => {
516526expect(calls.update).toEqual([]);
517527});
518528529+it("does not close GitHub App-authored PRs when stale PR-limit label removal returns 404", async () => {
530+const { calls, github } = barnacleGithub([file("README.md")], {
531+removeLabelNotFound: ["r: too-many-prs"],
532+});
533+534+await runBarnacleAutoResponse({
535+ github,
536+context: barnacleContext(
537+{
538+user: {
539+login: "renovate[bot]",
540+type: "Bot",
541+},
542+},
543+["r: too-many-prs"],
544+),
545+core: {
546+info: () => undefined,
547+},
548+});
549+550+expect(calls.removeLabel).toContainEqual(expect.objectContaining({ name: "r: too-many-prs" }));
551+expect(calls.createComment).toEqual([]);
552+expect(calls.update).toEqual([]);
553+});
554+519555it("still adds candidate labels to broad contributor PRs", async () => {
520556const { calls, github } = barnacleGithub([
521557file("ui/src/app.ts"),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。