Skip to content

Commit 91f60be

Browse files
authored
Merge pull request #77 from rspieldenner/dashes_slashes
Handle branch patterns with dashes and slashes
2 parents 0a14f88 + 90c959d commit 91f60be

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
4.2.0 / 2017-03-29
1+
4.2.0 / 2017-03-31
22
==================
33

44
* Calculate version in repository with no commits
5+
* Allow pushing tags from detached branch
6+
* Better handle branch patterns that would error out semver when put in dev version
57

68
4.0.1 / 2016-02-05
79
==================

README.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ This plugin provides opinions and tasks for the release process provided by [gra
1212
# Applying the plugin
1313

1414
plugins {
15-
id 'nebula.release' version '4.1.1'
15+
id 'nebula.release' version '4.2.0'
1616
}
1717

1818
-or-
1919

2020
buildscript {
2121
repositories { jcenter() }
2222
dependencies {
23-
classpath 'com.netflix.nebula:nebula-release-plugin:4.1.1'
23+
classpath 'com.netflix.nebula:nebula-release-plugin:4.2.0'
2424
}
2525
}
2626
apply plugin: 'nebula.nebula-release'
@@ -133,20 +133,14 @@ Tested with Oracle JDK8
133133

134134
| Gradle Version | Works |
135135
| :------------: | :---: |
136-
| 2.2.1 | yes |
137-
| 2.3 | yes |
138-
| 2.4 | yes |
139-
| 2.5 | yes |
140-
| 2.6 | yes |
141-
| 2.7 | yes |
142-
| 2.8 | yes |
143-
| 2.9 | yes |
144-
| 2.10 | yes |
136+
| 2.13 | yes |
137+
| 3.3 | yes |
138+
| 3.4.1 | yes |
145139

146140
LICENSE
147141
=======
148142

149-
Copyright 2014-2016 Netflix, Inc.
143+
Copyright 2014-2017 Netflix, Inc.
150144

151145
Licensed under the Apache License, Version 2.0 (the "License");
152146
you may not use this file except in compliance with the License.

src/integTest/groovy/nebula/plugin/release/GitVersioningIntegrationSpec.groovy

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ abstract class GitVersioningIntegrationSpec extends IntegrationSpec {
2727

2828
def setup() {
2929
def origin = new File(projectDir.parent, "${projectDir.name}.git")
30+
if (origin.exists()) {
31+
origin.deleteDir()
32+
}
3033
origin.mkdirs()
3134

3235
['build.gradle', 'settings.gradle'].each {

src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy

+20-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ package nebula.plugin.release
1717

1818
import nebula.plugin.bintray.NebulaBintrayPublishingPlugin
1919
import org.ajoberstar.grgit.Tag
20-
import org.ajoberstar.grgit.operation.BranchAddOp
21-
import org.ajoberstar.grgit.operation.BranchChangeOp
2220
import org.gradle.api.plugins.JavaPlugin
2321
import org.gradle.internal.impldep.com.amazonaws.util.Throwables
2422

@@ -525,4 +523,24 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {
525523

526524
originGit.branch.list().size() == 1
527525
}
526+
527+
def 'branches with slashes that do not match specified patterns do not fail builds'() {
528+
git.checkout(branch: 'dev/robtest', createBranch: true)
529+
530+
when:
531+
def version = inferredVersionForTask('devSnapshot')
532+
533+
then:
534+
version == dev('0.1.0-dev.2+dev.robtest.')
535+
}
536+
537+
def 'branches with dashes that do not match specified patterns do not fail builds'() {
538+
git.checkout(branch: 'dev-robtest', createBranch: true)
539+
540+
when:
541+
def version = inferredVersionForTask('devSnapshot')
542+
543+
then:
544+
version == dev('0.1.0-dev.2+dev.robtest.')
545+
}
528546
}

src/main/groovy/nebula/plugin/release/NetflixOssStrategies.groovy

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2015 Netflix, Inc.
2+
* Copyright 2014-2017 Netflix, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,8 +44,8 @@ class NetflixOssStrategies {
4444
needsBranchMetadata = false
4545
}
4646
}
47-
def shortenedBranch = (state.currentBranch.name =~ nebulaReleaseExtension.shortenedBranchPattern)[0][1]
48-
shortenedBranch = shortenedBranch.replaceAll('_', '.')
47+
String shortenedBranch = (state.currentBranch.name =~ nebulaReleaseExtension.shortenedBranchPattern)[0][1]
48+
shortenedBranch = shortenedBranch.replaceAll(/[_\/-]/, '.')
4949
def metadata = needsBranchMetadata ? "${shortenedBranch}.${state.currentHead.abbreviatedId}" : state.currentHead.abbreviatedId
5050
state.copyWith(inferredBuildMetadata: metadata)
5151
}

0 commit comments

Comments
 (0)