Skip to content

Commit

Permalink
build: handle unhandled promise rejection in notes (#24923)
Browse files Browse the repository at this point in the history
Handle any potential Git processes without throwing unhandled rejection errors.
  • Loading branch information
codebytere committed Aug 10, 2020
1 parent 047650b commit 16c32d2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
52 changes: 34 additions & 18 deletions script/release/notes/index.js
Original file line number Diff line number Diff line change
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
6 changes: 5 additions & 1 deletion script/release/prepare-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,8 @@ async function prepareRelease (isBeta, notesOnly) {
}
}

prepareRelease(!args.stable, args.notesOnly);
prepareRelease(!args.stable, args.notesOnly)
.catch((err) => {
console.error(err);
process.exit(1);
});

0 comments on commit 16c32d2

Please sign in to comment.