build: add --unique option to release notes script (#34296)

Useful when looking for changes unique to a single branch
This commit is contained in:
Charles Kerr 2022-06-06 00:51:10 -05:00 committed by GitHub
parent 4f99e3e46c
commit 92b0f3e808
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View file

@ -596,10 +596,14 @@ function renderDescription (commit) {
const renderNote = (commit, excludeBranch) =>
`* ${renderDescription(commit)} ${renderLink(commit)} ${renderTrops(commit, excludeBranch)}\n`;
const renderNotes = (notes) => {
const renderNotes = (notes, unique = false) => {
const rendered = [`# Release Notes for ${notes.name}\n\n`];
const renderSection = (title, commits) => {
const renderSection = (title, commits, unique) => {
if (unique) {
// omit changes that also landed in other branches
commits = commits.filter((commit) => renderTrops(commit, notes.toBranch).length === 0);
}
if (commits.length > 0) {
rendered.push(
`## ${title}\n\n`,
@ -608,17 +612,17 @@ const renderNotes = (notes) => {
}
};
renderSection('Breaking Changes', notes.breaking);
renderSection('Features', notes.feat);
renderSection('Fixes', notes.fix);
renderSection('Other Changes', notes.other);
renderSection('Breaking Changes', notes.breaking, unique);
renderSection('Features', notes.feat, unique);
renderSection('Fixes', notes.fix, unique);
renderSection('Other Changes', notes.other, unique);
if (notes.docs.length) {
const docs = notes.docs.map(commit => renderLink(commit)).sort();
rendered.push('## Documentation\n\n', ` * Documentation changes: ${docs.join(', ')}\n`, '\n');
}
renderSection('Unknown', notes.unknown);
renderSection('Unknown', notes.unknown, unique);
return rendered.join('');
};