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
+6 -3
View File
@@ -7,7 +7,10 @@ const {makeTag} = require('./utils');
*
* @typedef {Object} LastRelease
* @property {string} version The version number of the last release.
* @property {string} [gitHead] The Git reference used to make the last release.
* @property {string} gitHead The Git reference used to make the last release.
* @property {string} gitTag The git tag associated with the last release.
* @property {string} channel The channel on which of the last release was published.
* @property {string} name The name of the last release.
*/
/**
@@ -24,13 +27,13 @@ const {makeTag} = require('./utils');
* @return {LastRelease} The last tagged release or empty object if none is found.
*/
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
const [{version, gitTag, gitHead, channel} = {}] = branch.tags
const [{version, gitTag, channel} = {}] = branch.tags
.filter(tag => (branch.type === 'prerelease' && branch.channel === tag.channel) || !semver.prerelease(tag.version))
.filter(tag => isUndefined(before) || semver.lt(tag.version, before))
.sort((a, b) => semver.rcompare(a.version, b.version));
if (gitTag) {
return {version, gitTag, gitHead, channel, name: makeTag(tagFormat, version)};
return {version, gitTag, channel, gitHead: gitTag, name: makeTag(tagFormat, version)};
}
return {};