Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth committed May 25, 2021
1 parent 2715499 commit 718b9ae
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions lib/src/Gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,29 +371,12 @@ class Gren {
return this._getAllTags(releases, page + 1).then(moreTags => moreTags.concat(filteredTags));
}

return filteredTags;
}
for (const tag of filteredTags) {
const gotCommit = await this.repo.getCommit(tag.tag.commit.sha);
tag.commit = gotCommit.data;
}

/**
* Get the dates of the last two tags
*
* @since 0.1.0
* @private
*
* @param {Object[]} tags List of all the tags in the repo
*
* @return {Promise[]} The promises which returns the dates
*/
_getTagDates(tags) {
return tags.map(async tag => {
const { data: { committer } } = await this.repo.getCommit(tag.tag.commit.sha);

return {
id: tag.releaseId,
name: tag.tag.name,
date: committer.date
};
});
return filteredTags;
}

/**
Expand Down Expand Up @@ -1132,7 +1115,7 @@ class Gren {

this._validateRequiredTagsExists(tags, this.options.tags);

const releaseObjects = await this._transformTagsIntoReleaseObjects(tags);
const releaseObjects = this._transformTagsIntoReleaseObjects(tags);
const releaseDates = this._sortReleasesByDate(releaseObjects);
const selectedTags = (this._getSelectedTags(releaseDates) || (releaseDates.length > 1 ? [releaseDates[0], releaseDates[1]] : releaseDates));

Expand All @@ -1143,15 +1126,11 @@ class Gren {
);
}

async _transformTagsIntoReleaseObjects(tags) {
for (const tag of tags) {
tag.commit = await this.repo.getCommit(tag.tag.commit.sha);
}

_transformTagsIntoReleaseObjects(tags) {
return tags.map(tag => ({
id: tag.releaseId,
name: tag.tag.name,
date: tag.commit.data.committer.date
date: tag.commit ? tag.commit.committer.date : tag.date
}));
}

Expand Down

0 comments on commit 718b9ae

Please sign in to comment.