Skip to content

Commit f43df83

Browse files
gatesnclaude
andcommitted
Fetch RFC authors from PR branch for proposed RFCs
Instead of using the PR opener as the author, fetch the file content from the PR branch via GitHub API and parse the - Authors: field. Falls back to PR author if no authors field is found. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 79940bf commit f43df83

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

index.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface ProposedRFC {
3737
title: string;
3838
prNumber: number;
3939
prUrl: string;
40-
author: GitHubAuthor | null;
40+
authors: GitHubAuthor[];
4141
}
4242

4343
const THEME_SCRIPT = `
@@ -175,14 +175,14 @@ function indexPage(
175175
if (proposed.length > 0) {
176176
const proposedList = proposed
177177
.map((rfc) => {
178-
let authorHTML = "";
179-
if (rfc.author) {
180-
authorHTML = `
181-
<a href="${rfc.author.profileUrl}" class="rfc-author-link" title="${rfc.author.login}">
182-
<img src="${rfc.author.avatarUrl}" alt="${rfc.author.login}" class="rfc-author-avatar">
183-
<span class="rfc-author-name">${rfc.author.login}</span>
184-
</a>`;
185-
}
178+
const authorHTML = rfc.authors
179+
.map(
180+
(author) => `
181+
<a href="${author.profileUrl}" class="rfc-author-link" title="${author.login}">
182+
<img src="${author.avatarUrl}" alt="${author.login}" class="rfc-author-avatar">
183+
</a>`,
184+
)
185+
.join("");
186186

187187
return `
188188
<li>
@@ -512,7 +512,7 @@ async function getProposedRFCs(
512512
if (!repoPath) return [];
513513
try {
514514
const result =
515-
await $`gh pr list --repo ${repoPath} --state open --json number,title,url,files,author`.quiet();
515+
await $`gh pr list --repo ${repoPath} --state open --json number,title,url,files,author,headRefName`.quiet();
516516
const prs = JSON.parse(result.stdout.toString());
517517
const proposed: ProposedRFC[] = [];
518518

@@ -529,18 +529,30 @@ async function getProposedRFCs(
529529
const rfcNumber = rfcFile.path.match(/(\d{4})-/)?.[1];
530530
if (!rfcNumber) continue;
531531

532+
// Fetch file content from PR branch to parse authors
533+
let authors: GitHubAuthor[] = [];
534+
try {
535+
const fileResult =
536+
await $`gh api repos/${repoPath}/contents/${rfcFile.path}?ref=${pr.headRefName} --jq '.content'`.quiet();
537+
const content = atob(fileResult.stdout.toString().trim());
538+
const logins = parseAuthorLogins(content);
539+
if (logins.length > 0) {
540+
authors = loginsToAuthors(logins);
541+
}
542+
} catch {
543+
// Fall back to PR author
544+
}
545+
546+
if (authors.length === 0 && pr.author) {
547+
authors = loginsToAuthors([pr.author.login]);
548+
}
549+
532550
proposed.push({
533551
number: rfcNumber,
534552
title: pr.title,
535553
prNumber: pr.number,
536554
prUrl: pr.url,
537-
author: pr.author
538-
? {
539-
login: pr.author.login,
540-
avatarUrl: `https://github.com/${pr.author.login}.png?size=48`,
541-
profileUrl: `https://github.com/${pr.author.login}`,
542-
}
543-
: null,
555+
authors,
544556
});
545557
}
546558

0 commit comments

Comments
 (0)