Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix git semver tags recognize all tags #693

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 14 additions & 20 deletions packages/git-semver-tags/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
var proc = require('process')
var exec = require('child_process').exec
var semverValid = require('semver').valid
var regex = /tag:\s*(.+?)[,)]/gi
var cmd = 'git log --decorate --no-color'
var cmd = 'git tag --sort=-"v:refname"'
var unstableTagTest = /.*-\w*\.\d$/

function lernaTag (tag, pkg) {
Expand Down Expand Up @@ -38,28 +37,23 @@ module.exports = function gitSemverTags (opts, callback) {
if (options.tagPrefix) {
tagPrefixRegexp = new RegExp('^' + options.tagPrefix + '(.*)')
}
data.split('\n').forEach(function (decorations) {
var match
while ((match = regex.exec(decorations))) {
var tag = match[1]
data.split('\n').forEach(function (tag) {
if (options.skipUnstable && unstableTagTest.test(tag)) {
// skip unstable tag
return
}

if (options.skipUnstable && unstableTagTest.test(tag)) {
// skip unstable tag
continue
if (options.lernaTags) {
if (lernaTag(tag, options.package)) {
tags.push(tag)
}

if (options.lernaTags) {
if (lernaTag(tag, options.package)) {
tags.push(tag)
}
} else if (options.tagPrefix) {
var matches = tag.match(tagPrefixRegexp)
if (matches && semverValid(matches[1])) {
tags.push(tag)
}
} else if (semverValid(tag)) {
} else if (options.tagPrefix) {
var matches = tag.match(tagPrefixRegexp)
if (matches && semverValid(matches[1])) {
tags.push(tag)
}
} else if (semverValid(tag)) {
tags.push(tag)
}
})

Expand Down