From 131734873e904176044767ad929b5f53579556f6 Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Thu, 7 Nov 2019 14:16:23 -0500 Subject: [PATCH] fix: throws error if the commit associated with a tag cannot be found --- lib/git.js | 6 +----- test/git.test.js | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/git.js b/lib/git.js index db8447e9..a2956dde 100644 --- a/lib/git.js +++ b/lib/git.js @@ -14,11 +14,7 @@ Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', commi * @return {String} The commit sha of the tag in parameter or `null`. */ async function getTagHead(tagName, execaOpts) { - try { - return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; - } catch (error) { - debug(error); - } + return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; } /** diff --git a/test/git.test.js b/test/git.test.js index 34e5000d..7383f156 100644 --- a/test/git.test.js +++ b/test/git.test.js @@ -140,7 +140,7 @@ test('Get all branches', async t => { t.deepEqual((await getBranches(repositoryUrl, {cwd})).sort(), ['master', 'second-branch', 'third-branch'].sort()); }); -test('Get the commit sha for a given tag or falsy if the tag does not exists', async t => { +test('Get the commit sha for a given tag', async t => { // Create a git repository, set the current working directory at the root of the repo const {cwd} = await gitRepo(); // Add commits to the master branch @@ -149,7 +149,6 @@ test('Get the commit sha for a given tag or falsy if the tag does not exists', a await gitTagVersion('v1.0.0', undefined, {cwd}); t.is(await getTagHead('v1.0.0', {cwd}), commits[0].hash); - t.falsy(await getTagHead('missing_tag', {cwd})); }); test('Return git remote repository url from config', async t => {