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
23 changes: 13 additions & 10 deletions .github/workflows/maintainer-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function checkPerPathApproval(files, rulesWithTeams, approverLogins, githu

// --- Git history & scoring helpers ---

const MENTION_REVIEWERS = true;
const MENTION_REVIEWERS = false;
const OWNERS_LINK = "[OWNERS](.github/OWNERS)";
const MARKER = "<!-- MAINTAINER_APPROVAL -->";
const STATUS_CONTEXT = "maintainer-approval";
Expand Down Expand Up @@ -203,9 +203,8 @@ function topDirs(ds, n = 3) {
}

function fmtReviewer(login, dirs) {
const mention = MENTION_REVIEWERS ? `@${login}` : login;
const dirList = dirs.map((d) => `\`${d}/\``).join(", ");
return `- ${mention} -- recent work in ${dirList}`;
return `- ${fmtLogin(login)} -- recent work in ${dirList}`;
}

function selectReviewers(ss) {
Expand All @@ -221,8 +220,12 @@ function selectReviewers(ss) {
}

function fmtEligible(owners) {
if (MENTION_REVIEWERS) return owners.map((o) => `@${o}`).join(", ");
return owners.join(", ");
return owners.map((o) => fmtLogin(o)).join(", ");
}

function fmtLogin(login) {
if (MENTION_REVIEWERS) return `@${login}`;
return `\`@${login}\``;
}

async function countRecentReviews(github, owner, repo, logins, days = 30) {
Expand Down Expand Up @@ -267,7 +270,7 @@ function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, main

const approver = approvedBy.get(pattern);
if (approver) {
lines.push(`### \`${pattern}\` - approved by @${approver}`);
lines.push(`### \`${pattern}\` - approved by ${fmtLogin(approver)}`);
} else {
lines.push(`### \`${pattern}\` - needs approval`);
}
Expand All @@ -277,13 +280,13 @@ function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, main
const individuals = owners.filter(o => !o.includes("/") && o.toLowerCase() !== authorLower);

if (teams.length > 0) {
lines.push(`Teams: ${teams.map(t => `@${t}`).join(", ")}`);
lines.push(`Teams: ${teams.map(t => fmtLogin(t)).join(", ")}`);
}

if (!approver && individuals.length > 0) {
const scored = individuals.map(o => [o, scores[o] || 0]).sort((a, b) => b[1] - a[1]);
if (scored[0][1] > 0) {
lines.push(`Suggested: @${scored[0][0]}`);
lines.push(`Suggested: ${fmtLogin(scored[0][0])}`);
const rest = scored.slice(1).map(([o]) => o);
if (rest.length > 0) {
lines.push(`Also eligible: ${fmtEligible(rest)}`);
Expand Down Expand Up @@ -320,7 +323,7 @@ function buildPendingPerGroupComment(groups, scores, dirScores, approvedBy, main

const maintainerList = maintainers
.filter(m => m.toLowerCase() !== authorLower)
.map(m => `@${m}`)
.map(m => fmtLogin(m))
.join(", ");

lines.push(
Expand Down Expand Up @@ -349,7 +352,7 @@ function buildSingleDomainPendingComment(sortedScores, dirScores, scoredCount, e
} else if (roundRobinReviewer) {
lines.push(
"Could not determine reviewers from git history.",
`Round-robin suggestion: @${roundRobinReviewer}`,
`Round-robin suggestion: ${fmtLogin(roundRobinReviewer)}`,
""
);
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maintainer-approval.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe("maintainer-approval", () => {
assert.ok(body.includes("## Approval status: pending"));
assert.ok(body.includes("`/cmd/pipelines/`"));
assert.ok(body.includes("`/bundle/`"));
assert.ok(body.includes("approved by @jefferycheng1"));
assert.ok(body.includes("approved by `@jefferycheng1`"));
assert.ok(body.includes("needs approval"));
});
});
Loading