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

@ -147,7 +147,7 @@ const getPreviousPoint = async (point) => {
}
};
async function getReleaseNotes (range, newVersion) {
async function getReleaseNotes (range, newVersion, unique) {
const rangeList = range.split('..') || ['HEAD'];
const to = rangeList.pop();
const from = rangeList.pop() || (await getPreviousPoint(to));
@ -158,7 +158,7 @@ async function getReleaseNotes (range, newVersion) {
const notes = await notesGenerator.get(from, to, newVersion);
const ret = {
text: notesGenerator.render(notes)
text: notesGenerator.render(notes, unique)
};
if (notes.unknown.length) {
@ -170,7 +170,7 @@ async function getReleaseNotes (range, newVersion) {
async function main () {
const opts = minimist(process.argv.slice(2), {
boolean: ['help'],
boolean: ['help', 'unique'],
string: ['version']
});
opts.range = opts._.shift();
@ -179,13 +179,14 @@ async function main () {
console.log(`
easy usage: ${name} version
full usage: ${name} [begin..]end [--version version]
full usage: ${name} [begin..]end [--version version] [--unique]
* 'begin' and 'end' are two git references -- tags, branches, etc --
from which the release notes are generated.
* if omitted, 'begin' defaults to the previous tag in end's branch.
* if omitted, 'version' defaults to 'end'. Specifying a version is
useful if you're making notes on a new version that isn't tagged yet.
* '--unique' omits changes that also landed in other branches.
For example, these invocations are equivalent:
${process.argv[1]} v4.0.1
@ -194,7 +195,7 @@ For example, these invocations are equivalent:
return 0;
}
const notes = await getReleaseNotes(opts.range, opts.version);
const notes = await getReleaseNotes(opts.range, opts.version, opts.unique);
console.log(notes.text);
if (notes.warning) {
throw new Error(notes.warning);