Skip to content

Commit

Permalink
feat: include author name to commit info from github-codeowner-file
Browse files Browse the repository at this point in the history
… content extractor script
  • Loading branch information
azasypkin committed Jun 9, 2024
1 parent 0f09c9c commit b4010f4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions content-extractor-scripts/src/github-codeowner-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export async function run(context: WebPageContext, owner: string, repo: string,
try {
const commits = (await fetch(
`https://api.github.com/repos/${owner}/${repo}/commits?path=${encodeURIComponent(path)}&per_page=1`,
).then((response) => response.json())) as Array<{ html_url: string; commit: { author: { date: string } } }>;
).then((response) => response.json())) as Array<{
html_url: string;
commit: { author: { date: string; name: string } };
}>;
if (commits.length === 0) {
return 'N/A (no commits found)';
}
return `[${commits[0].commit.author.date}](${commits[0].html_url})`;
return `[${commits[0].commit.author.date} by ${commits[0].commit.author.name}](${commits[0].html_url})`;
} catch {
return 'N/A (error fetching commit)';
}
Expand Down

0 comments on commit b4010f4

Please sign in to comment.