Skip to content

Commit

Permalink
[core] Reference commits in changelog when no PR (mui#44115)
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Tassinari <[email protected]>
  • Loading branch information
oliviertassinari authored Oct 16, 2024
1 parent 9e2c3e4 commit 90b890a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/releaseChangelog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ async function findLatestTaggedVersion() {
return stdout.trim();
}

// Match commit messages like:
// "[docs] Fix small typo on Grid2 page (#44062)"
const prLinkRegEx = /\(#[0-9]+\)$/;

async function main(argv) {
const { githubToken, lastRelease: lastReleaseInput, release, repo } = argv;

Expand Down Expand Up @@ -156,7 +160,13 @@ async function main(argv) {
return aTags.localeCompare(bTags);
});
const changes = commitsItems.map((commitsItem) => {
const shortMessage = commitsItem.commit.message.split('\n')[0];
let shortMessage = commitsItem.commit.message.split('\n')[0];

// If the commit message doesn't have an associated PR, add the commit sha for reference.
if (!prLinkRegEx.test(shortMessage)) {
shortMessage += ` (${commitsItem.sha.substring(0, 7)})`;
}

return `- ${shortMessage} @${getAuthor(commitsItem)}`;
});
const nowFormatted = new Date().toLocaleDateString('en-US', {
Expand Down

0 comments on commit 90b890a

Please sign in to comment.