Skip to content

Commit

Permalink
List all authors in release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Feb 16, 2024
1 parent 0146b84 commit c9b3655
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions scripts/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare module 'github-api' {
data: { number: number; title: string; head: { sha: string } }[];
}>;

listCommitsOnPR(pr: number): Promise<{ data: { author: { login: string } }[] }>;

getPullRequest(pr: number): Promise<{ data: { body: string; user: { login: string } } }>;

createRelease(release: { body: string; name: string; tag_name: string }): Promise<void>;
Expand Down
4 changes: 2 additions & 2 deletions scripts/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ ${sections}### Pull Requests
${prs
.map(
({ text, pr, author }) =>
`- [#${pr}](https://github.com/rollup/rollup/pull/${pr}): ${text} (@${author})`
({ text, pr, authors }) =>
`- [#${pr}](https://github.com/rollup/rollup/pull/${pr}): ${text} (${authors.map(author => `@${author}`).join(', ')})`
)
.join('\n')}`;
}
Expand Down
14 changes: 10 additions & 4 deletions scripts/release-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function getFirstChangelogEntry(changelog) {

/**
* @typedef {object} IncludedPR
* @property {string} author
* @property {string[]} authors
* @property {number[]} closed - which PRs are closed by this
* @property {number} pr
* @property {string} text
Expand Down Expand Up @@ -72,15 +72,21 @@ export async function getIncludedPRs(fromVersion, toVersion, repo, currentBranch
prs.sort((a, b) => (a.pr > b.pr ? 1 : -1));
return Promise.all(
prs.map(async ({ pr, text }) => {
const { data } = await repo.getPullRequest(pr);
const bodyWithoutComments = data.body.replace(/<!--[\S\s]*?-->/g, '');
const [{ data: pullRequest }, { data: commits }] = await Promise.all([
repo.getPullRequest(pr),
repo.listCommitsOnPR(pr)
]);
const mainAuthor = pullRequest.user.login;
const otherAuthors = new Set(commits.map(({ author: { login } }) => login));
otherAuthors.delete(mainAuthor);
const bodyWithoutComments = pullRequest.body.replace(/<!--[\S\s]*?-->/g, '');
const closedIssuesRegexp = /([Ff]ix(es|ed)?|([Cc]lose|[Rr]esolve)[ds]?) #(\d+)/g;
const closed = [];
while ((match = closedIssuesRegexp.exec(bodyWithoutComments))) {
closed.push(Number(match[4]));
}
return {
author: data.user.login,
authors: [mainAuthor, ...otherAuthors],
closed,
pr,
text
Expand Down

0 comments on commit c9b3655

Please sign in to comment.