Skip to content

Commit

Permalink
[core] Fix release changelog to handle commits with empty author field (
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova authored Jan 23, 2023
1 parent 6311da5 commit 160e66c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions scripts/releaseChangelog.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-restricted-syntax */
import { Octokit } from '@octokit/rest';
import chalk from 'chalk';
import childProcess from 'child_process';
import { promisify } from 'util';
import yargs from 'yargs';
Expand Down Expand Up @@ -94,10 +95,26 @@ async function main(argv) {
commitsItems.push(...compareCommits.commits.filter(filterCommit));
}

let warnedOnce = false;

const getAuthor = (commit) => {
if (!commit.author) {
if (!warnedOnce) {
console.warn(
`The author of the commit: ${commit.commit.tree.url} cannot be retrieved. Please add the github username manually.`,
);
}
warnedOnce = true;
return chalk.red("TODO INSERT AUTHOR'S USERNAME");
}

return commit.author?.login;
};

const authors = Array.from(
new Set(
commitsItems.map((commitsItem) => {
return commitsItem.author.login;
return getAuthor(commitsItem);
}),
),
);
Expand Down Expand Up @@ -128,7 +145,7 @@ async function main(argv) {
// i.e. we can sort the lines alphanumerically
.padStart(Math.floor(Math.log10(commitsItemsByDateDesc.length)) + 1, '0')} -->`;
const shortMessage = commitsItem.commit.message.split('\n')[0];
return `- ${dateSortMarker}${shortMessage} @${commitsItem.author.login}`;
return `- ${dateSortMarker}${shortMessage} @${getAuthor(commitsItem)}`;
});
const nowFormatted = new Date().toLocaleDateString('en-US', {
month: 'short',
Expand Down

0 comments on commit 160e66c

Please sign in to comment.