Skip to content

Commit

Permalink
fix: throws error if the commit associated with a tag cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Nov 7, 2019
1 parent de77a79 commit 1317348
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 1 addition & 5 deletions lib/git.js
Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions test/git.test.js
Expand Up @@ -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
Expand All @@ -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 => {
Expand Down

0 comments on commit 1317348

Please sign in to comment.