perf: use git tag --merge <branch> to filter tags present in a branch history

BREAKING CHANGE: Git CLI version 2.7.1 or higher is now required

The `--merge` option of the `git tag` command has been added in Git version 2.7.1 and is now used by semantic-release
This commit is contained in:
Pierre Vanduynslager
2019-11-01 16:58:55 -04:00
parent 844e0b07e0
commit cffe9a8d33
6 changed files with 23 additions and 25 deletions
+4 -3
View File
@@ -22,15 +22,16 @@ async function getTagHead(tagName, execaOpts) {
}
/**
* Get all the repository tags.
* Get all the tags for a given branch.
*
* @param {String} branch The branch for which to retrieve the tags.
* @param {Object} [execaOpts] Options to pass to `execa`.
*
* @return {Array<String>} List of git tags.
* @throws {Error} If the `git` command fails.
*/
async function getTags(execaOpts) {
return (await execa('git', ['tag'], execaOpts)).stdout
async function getTags(branch, execaOpts) {
return (await execa('git', ['tag', '--merged', branch], execaOpts)).stdout
.split('\n')
.map(tag => tag.trim())
.filter(Boolean);