build: handle unhandled promise rejection in notes (#24923)
Handle any potential Git processes without throwing unhandled rejection errors.
This commit is contained in:
parent
047650b564
commit
16c32d2eb2
2 changed files with 39 additions and 19 deletions
|
@ -11,6 +11,7 @@ const notesGenerator = require('./notes.js');
|
||||||
const semverify = version => version.replace(/^origin\//, '').replace(/[xy]/g, '0').replace(/-/g, '.');
|
const semverify = version => version.replace(/^origin\//, '').replace(/[xy]/g, '0').replace(/-/g, '.');
|
||||||
|
|
||||||
const runGit = async (args) => {
|
const runGit = async (args) => {
|
||||||
|
console.info(`Running: git ${args.join(' ')}`);
|
||||||
const response = await GitProcess.exec(args, ELECTRON_DIR);
|
const response = await GitProcess.exec(args, ELECTRON_DIR);
|
||||||
if (response.exitCode !== 0) {
|
if (response.exitCode !== 0) {
|
||||||
throw new Error(response.stderr.trim());
|
throw new Error(response.stderr.trim());
|
||||||
|
@ -19,15 +20,20 @@ const runGit = async (args) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const tagIsSupported = tag => tag && !tag.includes('nightly') && !tag.includes('unsupported');
|
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 tagIsStable = tag => tagIsSupported(tag) && !tagIsBeta(tag);
|
||||||
|
|
||||||
const getTagsOf = async (point) => {
|
const getTagsOf = async (point) => {
|
||||||
return (await runGit(['tag', '--merged', point]))
|
try {
|
||||||
.split('\n')
|
const tags = await runGit(['tag', '--merged', point]);
|
||||||
.map(tag => tag.trim())
|
return tags.split('\n')
|
||||||
.filter(tag => semver.valid(tag))
|
.map(tag => tag.trim())
|
||||||
.sort(semver.compare);
|
.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) => {
|
const getTagsOnBranch = async (point) => {
|
||||||
|
@ -41,21 +47,31 @@ const getTagsOnBranch = async (point) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getBranchOf = async (point) => {
|
const getBranchOf = async (point) => {
|
||||||
const branches = (await runGit(['branch', '-a', '--contains', point]))
|
try {
|
||||||
.split('\n')
|
const branches = (await runGit(['branch', '-a', '--contains', point]))
|
||||||
.map(branch => branch.trim())
|
.split('\n')
|
||||||
.filter(branch => !!branch);
|
.map(branch => branch.trim())
|
||||||
const current = branches.find(branch => branch.startsWith('* '));
|
.filter(branch => !!branch);
|
||||||
return current ? current.slice(2) : branches.shift();
|
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 () => {
|
const getAllBranches = async () => {
|
||||||
return (await runGit(['branch', '--remote']))
|
try {
|
||||||
.split('\n')
|
const branches = await runGit(['branch', '--remote']);
|
||||||
.map(branch => branch.trim())
|
return branches.split('\n')
|
||||||
.filter(branch => !!branch)
|
.map(branch => branch.trim())
|
||||||
.filter(branch => branch !== 'origin/HEAD -> origin/master')
|
.filter(branch => !!branch)
|
||||||
.sort();
|
.filter(branch => branch !== 'origin/HEAD -> origin/master')
|
||||||
|
.sort();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to fetch all branches');
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStabilizationBranches = async () => {
|
const getStabilizationBranches = async () => {
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue