fix: correct git merge-base
error code handling
This commit is contained in:
parent
20245b733a
commit
4352144a98
@ -36,9 +36,15 @@ async function gitTags() {
|
||||
*/
|
||||
async function isRefInHistory(ref) {
|
||||
try {
|
||||
return (await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'])).code === 0;
|
||||
await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD']);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.code === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
debug(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,7 @@ test.serial('Verify if the commit `sha` is in the direct history of the current
|
||||
|
||||
t.true(await isRefInHistory(commits[0].hash));
|
||||
t.falsy(await isRefInHistory(otherCommits[0].hash));
|
||||
await t.throws(isRefInHistory('non-existant-sha'));
|
||||
});
|
||||
|
||||
test.serial('Get the commit sha for a given tag or falsy if the tag does not exists', async t => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user