Skip to content

Commit

Permalink
Merge pull request #77 from rspieldenner/dashes_slashes
Browse files Browse the repository at this point in the history
Handle branch patterns with dashes and slashes
  • Loading branch information
rspieldenner committed Apr 3, 2017
2 parents 0a14f88 + 90c959d commit 91f60be
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,9 @@
4.2.0 / 2017-03-29
4.2.0 / 2017-03-31
==================

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

4.0.1 / 2016-02-05
==================
Expand Down
18 changes: 6 additions & 12 deletions README.md
Expand Up @@ -12,15 +12,15 @@ This plugin provides opinions and tasks for the release process provided by [gra
# Applying the plugin

plugins {
id 'nebula.release' version '4.1.1'
id 'nebula.release' version '4.2.0'
}

-or-

buildscript {
repositories { jcenter() }
dependencies {
classpath 'com.netflix.nebula:nebula-release-plugin:4.1.1'
classpath 'com.netflix.nebula:nebula-release-plugin:4.2.0'
}
}
apply plugin: 'nebula.nebula-release'
Expand Down Expand Up @@ -133,20 +133,14 @@ Tested with Oracle JDK8

| Gradle Version | Works |
| :------------: | :---: |
| 2.2.1 | yes |
| 2.3 | yes |
| 2.4 | yes |
| 2.5 | yes |
| 2.6 | yes |
| 2.7 | yes |
| 2.8 | yes |
| 2.9 | yes |
| 2.10 | yes |
| 2.13 | yes |
| 3.3 | yes |
| 3.4.1 | yes |

LICENSE
=======

Copyright 2014-2016 Netflix, Inc.
Copyright 2014-2017 Netflix, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Expand Up @@ -27,6 +27,9 @@ abstract class GitVersioningIntegrationSpec extends IntegrationSpec {

def setup() {
def origin = new File(projectDir.parent, "${projectDir.name}.git")
if (origin.exists()) {
origin.deleteDir()
}
origin.mkdirs()

['build.gradle', 'settings.gradle'].each {
Expand Down
Expand Up @@ -17,8 +17,6 @@ package nebula.plugin.release

import nebula.plugin.bintray.NebulaBintrayPublishingPlugin
import org.ajoberstar.grgit.Tag
import org.ajoberstar.grgit.operation.BranchAddOp
import org.ajoberstar.grgit.operation.BranchChangeOp
import org.gradle.api.plugins.JavaPlugin
import org.gradle.internal.impldep.com.amazonaws.util.Throwables

Expand Down Expand Up @@ -525,4 +523,24 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec {

originGit.branch.list().size() == 1
}

def 'branches with slashes that do not match specified patterns do not fail builds'() {
git.checkout(branch: 'dev/robtest', createBranch: true)

when:
def version = inferredVersionForTask('devSnapshot')

then:
version == dev('0.1.0-dev.2+dev.robtest.')
}

def 'branches with dashes that do not match specified patterns do not fail builds'() {
git.checkout(branch: 'dev-robtest', createBranch: true)

when:
def version = inferredVersionForTask('devSnapshot')

then:
version == dev('0.1.0-dev.2+dev.robtest.')
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 Netflix, Inc.
* Copyright 2014-2017 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,8 +44,8 @@ class NetflixOssStrategies {
needsBranchMetadata = false
}
}
def shortenedBranch = (state.currentBranch.name =~ nebulaReleaseExtension.shortenedBranchPattern)[0][1]
shortenedBranch = shortenedBranch.replaceAll('_', '.')
String shortenedBranch = (state.currentBranch.name =~ nebulaReleaseExtension.shortenedBranchPattern)[0][1]
shortenedBranch = shortenedBranch.replaceAll(/[_\/-]/, '.')
def metadata = needsBranchMetadata ? "${shortenedBranch}.${state.currentHead.abbreviatedId}" : state.currentHead.abbreviatedId
state.copyWith(inferredBuildMetadata: metadata)
}
Expand Down

0 comments on commit 91f60be

Please sign in to comment.