Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,18 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
!new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists()
}

def 'using v as tag fails when running tasks'() {
git.tag.add(name: "v3.1.2")
git.tag.add(name: "v")

when:
def result = runTasksWithFailure('final', '-Prelease.useLastTag=true')

then:
result.standardError.contains "Tag name 'v' is invalid. 'v' should be use as prefix for semver versions only, example: v1.0.0"
!new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists()
}

def 'useLastTag uses release tag when running "final"'() {
git.tag.add(name: "v3.1.2-rc.1")
git.tag.add(name: "v3.1.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.github.zafarkhaja.semver.Version
import groovy.transform.CompileDynamic
import org.ajoberstar.grgit.Grgit
import org.ajoberstar.grgit.Tag
import org.gradle.api.GradleException
import org.slf4j.Logger
import org.slf4j.LoggerFactory

Expand All @@ -40,6 +41,9 @@ class TagStrategy {
*/
Closure<Version> parseTag = { Tag tag ->
try {
if(tag.name == 'v') {
throw new GradleException("Tag name 'v' is invalid. 'v' should be use as prefix for semver versions only, example: v1.0.0")
}
Version.valueOf(tag.name[0] == 'v' ? tag.name[1..-1] : tag.name)
} catch (ParseException e) {
null
Expand Down