Last tags don't filter current branch
maciejwajda opened this issue · 0 comments
maciejwajda commented
Last tags don't filter on current branch but use all branches tags, equivalent of git tag
instead of git tag --merged
.
This can be fixed here net.nemerosa.versioning.git.GitInfoService#getLastTags
e.g.
List<String> getLastTags(Project project, VersioningExtension extension, String tagPattern) {
// Git access
//noinspection GroovyAssignabilityCheck
def grgit = Grgit.open(currentDir: getGitDirectory(extension, project))
def branchCommits = grgit.log(maxCommits: 10000)*.id
// List all tags
return grgit.tag.list()
// ... filters using the pattern and commits from current branch
.findAll { (it.name =~ tagPattern).find() && branchCommits.contains(it.commit.id) }
.sort{ a,b ->
// ... sort by desc commit time
b.commit.dateTime.toEpochSecond() <=> a.commit.dateTime.toEpochSecond() ?:
// ... (#36) commit time is not enough. We have also to consider the case where several pattern compliant tags
// ... are on the same commit, and we must sort them by desc version
TagSupport.tagOrder(tagPattern, b.name) <=> TagSupport.tagOrder(tagPattern, a.name)
// ... gets their name only
}*.name
}