Skip to content

Commit

Permalink
Handle scenario where branch name contains double hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Jun 21, 2024
1 parent c83315c commit 1ebab89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationTestKitSpec {
version == dev('0.1.0-dev.2+testexample.')
}

def 'build on non standard branch with double hyphen fails with right context'() {
git.checkout(branch: 'test--example', createBranch: true)

when:
def result = runTasksAndFail('devSnapshot')

then:
result.output.contains("Branch test--example is invalid. Nebula Release plugin does not support branches that contain double dash (-) as it leads to bad build metadata for SemVer")
}

def 'choose devSnapshot version'() {
when:
def version = inferredVersionForTask('devSnapshot')
Expand Down
7 changes: 6 additions & 1 deletion src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,12 @@ class ReleasePlugin implements Plugin<Project> {
return
}
if (currentBranch.endsWith('-')) {
throw new GradleException('Nebula Release plugin does not support branches that end with dash (-)')
throw new GradleException('Nebula Release plugin does not support branches that end with dash (-).' +
'Please rename your branch')
}
if (currentBranch.contains('--')) {
throw new GradleException("Branch ${currentBranch} is invalid. Nebula Release plugin does not support branches that contain double dash (-) as it leads to bad build metadata for SemVer." +
" Please rename your branch")
}
if (currentBranch ==~ /release\/\d+(\.\d+)?/) {
throw new GradleException('Branches with pattern release/<version> are used to calculate versions. The version must be of form: <major>.x, <major>.<minor>.x, or <major>.<minor>.<patch>')
Expand Down

0 comments on commit 1ebab89

Please sign in to comment.