Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion action/contribution.mts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,16 @@ export async function validateContributionAuthors(
};
}

const GITHUB_SERVICE_LOGINS = new Set(["web-flow"]);

function isBot(user: GHUserLike | null): boolean {
if (!user) return false;
return user.type === "Bot" || isBotLogin(user.login);
}

function isBotLogin(login: string): boolean {
return typeof login === "string" && login.endsWith("[bot]");
if (typeof login !== "string") return false;
if (login.endsWith("[bot]")) return true;
if (GITHUB_SERVICE_LOGINS.has(login)) return true;
return false;
}
27 changes: 27 additions & 0 deletions action/test/dispatch_test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,33 @@ Deno.test("contribution ignores Co-authored-by trailers in commit messages", asy
assertEquals(result.contribution.ok, true);
});

Deno.test("contribution filters web-flow (GitHub UI commits) from the author set", async () => {
mockFetch({
"/repos/y/s/pulls/1/commits?per_page=100": {
body: [
{
sha: "abc1234",
author: { login: "benjick", type: "User" },
committer: { login: "web-flow", type: "User" },
commit: {
author: { email: "b@e.com" },
committer: { email: "noreply@github.com" },
},
},
],
},
"/repos/y/s/contents/CLA.md?ref=h": contentsResp(claText("1.0")),
"/repos/y/s/contents/.signatures/cla/benjick.md?ref=h": contentsResp(
sigText("1.0"),
),
});

const files: PRFile[] = [{ filename: "README.md" }];
const result = await dispatch(makeCtx(), files);

assertEquals(result.contribution.ok, true);
});

Deno.test("contribution filters bot logins from the author set", async () => {
mockFetch({
"/repos/y/s/pulls/1/commits?per_page=100": {
Expand Down
Loading