fix: call getTagHead only when necessary

This commit is contained in:
Pierre Vanduynslager
2019-11-07 14:33:53 -05:00
parent 56186419a7
commit de77a799a8
8 changed files with 113 additions and 102 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ const {template, escapeRegExp} = require('lodash');
const semver = require('semver');
const pReduce = require('p-reduce');
const debug = require('debug')('semantic-release:get-tags');
const {getTags, getTagHead} = require('../../lib/git');
const {getTags} = require('../../lib/git');
module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
// Generate a regex to parse tags formatted with `tagFormat`
@@ -21,7 +21,7 @@ module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
return {gitTag: tag, version, channel};
})
.filter(({version}) => version && semver.valid(semver.clean(version)))
.map(async ({gitTag, ...rest}) => ({gitTag, gitHead: await getTagHead(gitTag, {cwd, env}), ...rest}))
.map(async ({gitTag, ...rest}) => ({gitTag, ...rest}))
);
debug('found tags for branch %s: %o', branch.name, branchTags);