Skip to content

Commit e47a744

Browse files
fix(ci): GitHub App active-PR-limit exemption regression (#75311)
Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
1 parent 1ad50a3 commit e47a744

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

scripts/github/barnacle-auto-response.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,12 +808,12 @@ async function removeLabels(github, context, issueNumber, labels, labelSet) {
808808
issue_number: issueNumber,
809809
name: label,
810810
});
811-
labelSet.delete(label);
812811
} catch (error) {
813812
if (error?.status !== 404) {
814813
throw error;
815814
}
816815
}
816+
labelSet.delete(label);
817817
}
818818
}
819819

test/scripts/barnacle-auto-response.test.ts

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,16 @@ function barnacleIssueContext(
105105

106106
function barnacleGithub(
107107
files: 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
) {
110114
const maintainerLogins = new Set(
111115
(options.maintainerLogins ?? []).map((login) => login.toLowerCase()),
112116
);
117+
const removeLabelNotFound = new Set(options.removeLabelNotFound ?? []);
113118
const repositoryRoles = Object.fromEntries(
114119
Object.entries(options.repositoryRoles ?? {}).map(([login, role]) => [
115120
login.toLowerCase(),
@@ -147,6 +152,11 @@ function barnacleGithub(
147152
},
148153
removeLabel: async (params: { issue_number: number; name: string }) => {
149154
calls.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
},
151161
update: async (params: { issue_number: number; state?: string }) => {
152162
calls.update.push(params);
@@ -516,6 +526,32 @@ describe("barnacle-auto-response", () => {
516526
expect(calls.update).toEqual([]);
517527
});
518528

529+
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+
519555
it("still adds candidate labels to broad contributor PRs", async () => {
520556
const { calls, github } = barnacleGithub([
521557
file("ui/src/app.ts"),

0 commit comments

Comments
 (0)