Skip to content

Commit

Permalink
Merge pull request #177 from nebula-plugins/enhance-wrong-tag-messaging
Browse files Browse the repository at this point in the history
OverrideStrategies: print more context around bad tags when releasing candidates or final
  • Loading branch information
rpalcolea committed Feb 9, 2020
2 parents b726876 + 70981b3 commit 7ec8079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
def result = runTasksWithFailure('final', '-Prelease.useLastTag=true')

then:
result.standardError.contains "Current tag does not appear to be a final version"
result.standardError.contains "Current tag (3.1.2-rc.1) does not appear to be a final version"
!new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists()
}

Expand All @@ -650,7 +650,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
def result = runTasksWithFailure('candidate', '-Prelease.useLastTag=true')

then:
result.standardError.contains "Current tag does not appear to be a prerelease version"
result.standardError.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/"
!new File(projectDir, "build/libs/${moduleName}-3.1.2-rc.1.jar").exists()
!new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists()
}
Expand Down Expand Up @@ -815,7 +815,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
def result = runTasksWithFailure('candidate', '-Prelease.useLastTag=true')

then:
result.standardError.contains "Current tag does not appear to be a prerelease version"
result.standardError.contains "Current tag (3.1.2) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/"
!new File(projectDir, "build/libs/${moduleName}-3.1.2.jar").exists()
}

Expand Down Expand Up @@ -988,7 +988,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
def result = runTasksWithFailure('final', '-Prelease.useLastTag=true')

then:
result.standardError.contains 'Current tag does not appear to be a final version'
result.standardError.contains 'Current tag (3.1.2-release2) does not appear to be a final version'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nebula.plugin.release

import com.github.zafarkhaja.semver.Version
import nebula.plugin.release.git.base.ReleasePluginExtension
import nebula.plugin.release.git.base.ReleaseVersion
import nebula.plugin.release.git.base.VersionStrategy
Expand Down Expand Up @@ -85,15 +86,16 @@ class OverrideStrategies {
throw new GradleException("Current commit has a snapshot, immutableSnapshot or devSnapshot tag. 'useLastTag' requires a prerelease or final tag.")
}

def preReleaseVersion = locate.any.preReleaseVersion
Version version = locate.any
def preReleaseVersion = version.preReleaseVersion
if (releaseStage == 'rc') {
if (!(preReleaseVersion ==~ /rc\.\d+/)) {
throw new GradleException("Current tag does not appear to be a prerelease version")
throw new GradleException("Current tag ($version) does not appear to be a pre-release version. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/")
}
}
if (releaseStage == 'final') {
if (preReleaseVersion) {
throw new GradleException("Current tag does not appear to be a final version")
throw new GradleException("Current tag ($version) does not appear to be a final version. final task can not be used with prerelease versions. A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. For more information, please refer to https://semver.org/")
}
}

Expand Down

0 comments on commit 7ec8079

Please sign in to comment.