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
11 changes: 9 additions & 2 deletions .github/workflows/maintainer-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ async function selectRoundRobin(github, owner, repo, eligibleOwners, prAuthor) {

// --- Comment builders ---

function fmtFileList(files) {
if (files.length < 4) {
return `Files: ${files.map(f => `\`${f}\``).join(", ")}`;
}
return `${files.length} files changed`;
}

function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, maintainers, prAuthor) {
const authorLower = (prAuthor || "").toLowerCase();
const lines = [MARKER, "## Approval status: pending", ""];
Expand All @@ -274,7 +281,7 @@ function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, main
} else {
lines.push(`### \`${pattern}\` - needs approval`);
}
lines.push(`Files: ${files.map(f => `\`${f}\``).join(", ")}`);
lines.push(fmtFileList(files));

const teams = owners.filter(o => o.includes("/"));
const individuals = owners.filter(o => !o.includes("/") && o.toLowerCase() !== authorLower);
Expand All @@ -301,7 +308,7 @@ function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, main
const starGroup = groups.get("*");
if (starGroup) {
lines.push("### General files (require maintainer)");
lines.push(`Files: ${starGroup.files.map(f => `\`${f}\``).join(", ")}`);
lines.push(fmtFileList(starGroup.files));

const maintainerSet = new Set(maintainers.map(m => m.toLowerCase()));
const maintainerScores = Object.entries(scores)
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/maintainer-approval.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,4 +515,47 @@ describe("maintainer-approval", () => {
assert.ok(body.includes("approved by `@jefferycheng1`"));
assert.ok(body.includes("needs approval"));
});

it("lists individual files when fewer than 4 in a group", async () => {
const github = makeGithub({
reviews: [],
files: [
{ filename: "cmd/pipelines/foo.go" },
{ filename: "bundle/config.go" },
{ filename: "bundle/deploy.go" },
],
});
const core = makeCore();
const context = makeContext();

await runModule({ github, context, core });

assert.equal(github._comments.length, 1);
const body = github._comments[0].body;
assert.ok(body.includes("Files:"), "should list individual files");
assert.ok(body.includes("`bundle/config.go`"));
assert.ok(body.includes("`bundle/deploy.go`"));
});

it("shows file count instead of listing when 4 or more files in a group", async () => {
const github = makeGithub({
reviews: [],
files: [
{ filename: "cmd/pipelines/foo.go" },
{ filename: "bundle/a.go" },
{ filename: "bundle/b.go" },
{ filename: "bundle/c.go" },
{ filename: "bundle/d.go" },
],
});
const core = makeCore();
const context = makeContext();

await runModule({ github, context, core });

assert.equal(github._comments.length, 1);
const body = github._comments[0].body;
assert.ok(body.includes("4 files changed"), "should show count for bundle group");
assert.ok(!body.includes("`bundle/a.go`"), "should not list individual bundle files");
});
});
Loading