diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy index 44320a9..3a541af 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy @@ -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") diff --git a/src/main/groovy/nebula/plugin/release/git/base/TagStrategy.groovy b/src/main/groovy/nebula/plugin/release/git/base/TagStrategy.groovy index 9300665..9da66e0 100644 --- a/src/main/groovy/nebula/plugin/release/git/base/TagStrategy.groovy +++ b/src/main/groovy/nebula/plugin/release/git/base/TagStrategy.groovy @@ -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 @@ -40,6 +41,9 @@ class TagStrategy { */ Closure 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