Skip to content

Commit

Permalink
chore: sync 10-x-y release notes script to master (#25304)
Browse files Browse the repository at this point in the history
* chore: sync 10-x-y release notes script to master

* adds the '(Also in N-x-y)' annotations
* handle sublists in release notes (#25279)
* has prepare-release.js catch thrown exceptions (#24923)
* syncs related tests

* chore: update cache entries in release notes tests
  • Loading branch information
ckerr committed Sep 8, 2020
1 parent f99afa4 commit c6eeff8
Show file tree
Hide file tree
Showing 34 changed files with 620 additions and 256 deletions.
64 changes: 39 additions & 25 deletions script/release/notes/index.js
Expand Up @@ -11,6 +11,7 @@ const notesGenerator = require('./notes.js');
const semverify = version => version.replace(/^origin\//, '').replace(/[xy]/g, '0').replace(/-/g, '.');

const runGit = async (args) => {
console.info(`Running: git ${args.join(' ')}`);
const response = await GitProcess.exec(args, ELECTRON_DIR);
if (response.exitCode !== 0) {
throw new Error(response.stderr.trim());
Expand All @@ -19,15 +20,20 @@ const runGit = async (args) => {
};

const tagIsSupported = tag => tag && !tag.includes('nightly') && !tag.includes('unsupported');
const tagIsBeta = tag => tag.includes('beta');
const tagIsBeta = tag => tag && tag.includes('beta');
const tagIsStable = tag => tagIsSupported(tag) && !tagIsBeta(tag);

const getTagsOf = async (point) => {
return (await runGit(['tag', '--merged', point]))
.split('\n')
.map(tag => tag.trim())
.filter(tag => semver.valid(tag))
.sort(semver.compare);
try {
const tags = await runGit(['tag', '--merged', point]);
return tags.split('\n')
.map(tag => tag.trim())
.filter(tag => semver.valid(tag))
.sort(semver.compare);
} catch (err) {
console.error(`Failed to fetch tags for point ${point}`);
throw err;
}
};

const getTagsOnBranch = async (point) => {
Expand All @@ -41,21 +47,31 @@ const getTagsOnBranch = async (point) => {
};

const getBranchOf = async (point) => {
const branches = (await runGit(['branch', '-a', '--contains', point]))
.split('\n')
.map(branch => branch.trim())
.filter(branch => !!branch);
const current = branches.find(branch => branch.startsWith('* '));
return current ? current.slice(2) : branches.shift();
try {
const branches = (await runGit(['branch', '-a', '--contains', point]))
.split('\n')
.map(branch => branch.trim())
.filter(branch => !!branch);
const current = branches.find(branch => branch.startsWith('* '));
return current ? current.slice(2) : branches.shift();
} catch (err) {
console.error(`Failed to fetch branch for ${point}: `, err);
throw err;
}
};

const getAllBranches = async () => {
return (await runGit(['branch', '--remote']))
.split('\n')
.map(branch => branch.trim())
.filter(branch => !!branch)
.filter(branch => branch !== 'origin/HEAD -> origin/master')
.sort();
try {
const branches = await runGit(['branch', '--remote']);
return branches.split('\n')
.map(branch => branch.trim())
.filter(branch => !!branch)
.filter(branch => branch !== 'origin/HEAD -> origin/master')
.sort();
} catch (err) {
console.error('Failed to fetch all branches');
throw err;
}
};

const getStabilizationBranches = async () => {
Expand Down Expand Up @@ -120,7 +136,7 @@ const getPreviousPoint = async (point) => {
}
};

async function getReleaseNotes (range, newVersion, explicitLinks) {
async function getReleaseNotes (range, newVersion) {
const rangeList = range.split('..') || ['HEAD'];
const to = rangeList.pop();
const from = rangeList.pop() || (await getPreviousPoint(to));
Expand All @@ -129,10 +145,9 @@ async function getReleaseNotes (range, newVersion, explicitLinks) {
newVersion = to;
}

console.log(`Generating release notes between ${from} and ${to} for version ${newVersion}`);
const notes = await notesGenerator.get(from, to, newVersion);
const ret = {
text: notesGenerator.render(notes, explicitLinks)
text: notesGenerator.render(notes)
};

if (notes.unknown.length) {
Expand All @@ -144,7 +159,7 @@ async function getReleaseNotes (range, newVersion, explicitLinks) {

async function main () {
const opts = minimist(process.argv.slice(2), {
boolean: ['explicit-links', 'help'],
boolean: ['help'],
string: ['version']
});
opts.range = opts._.shift();
Expand All @@ -153,14 +168,13 @@ async function main () {
console.log(`
easy usage: ${name} version
full usage: ${name} [begin..]end [--version version] [--explicit-links]
full usage: ${name} [begin..]end [--version version]
* '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.
* 'explicit-links' makes every note's issue, commit, or pull an MD link
For example, these invocations are equivalent:
${process.argv[1]} v4.0.1
Expand All @@ -169,7 +183,7 @@ For example, these invocations are equivalent:
return 0;
}

const notes = await getReleaseNotes(opts.range, opts.version, opts['explicit-links']);
const notes = await getReleaseNotes(opts.range, opts.version);
console.log(notes.text);
if (notes.warning) {
throw new Error(notes.warning);
Expand Down

0 comments on commit c6eeff8

Please sign in to comment.