Skip to content

Commit

Permalink
Adds validation for scmVersion.nextVersion.suffix - can't be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdubiel committed May 30, 2020
1 parent 46c7a30 commit 21368b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ class BaseIntegrationTest extends RepositoryBasedTest {
BuildResult runGradle(String... arguments) {
return gradle().withArguments(arguments).build()
}

BuildResult runGradleAndFail(String... arguments) {
return gradle().withArguments(arguments).buildAndFail()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package pl.allegro.tech.build.axion.release

import org.gradle.testkit.runner.TaskOutcome

class NextVersionIntegrationTest extends BaseIntegrationTest {

def "should fail when passing empty nextVersion.suffix"() {
given:
buildFile(
"""
scmVersion {
nextVersion {
suffix = ''
}
}
"""
)

when:
def result = runGradleAndFail('currentVersion')

then:
result.output.contains("scmVersion.nextVersion.suffix can't be empty!")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class NextVersionPropertiesFactory {
private static final String DEPRECATED_NEXT_VERSION_PROPERTY = "release.nextVersion"

static NextVersionProperties create(Project project, NextVersionConfig config) {
if (config.suffix == null || config.suffix.isEmpty()) {
String message = "scmVersion.nextVersion.suffix can't be empty! Empty suffix will prevent axion-release from distinguishing nextVersion from regular versions";
project.logger.error(message)
throw new IllegalArgumentException(message)
}

String nextVersion = project.hasProperty(NEXT_VERSION_PROPERTY) ? project.property(NEXT_VERSION_PROPERTY) : null
String versionIncrementerName = project.hasProperty(NEXT_VERSION_INCREMENTER_PROPERTY) ? project.property(NEXT_VERSION_INCREMENTER_PROPERTY) : null

Expand Down

0 comments on commit 21368b6

Please sign in to comment.