diff --git a/README.md b/README.md index 92de2ec..bd94354 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ All tasks default to bumping the minor version. # Extension Provided nebulaRelease { - Set releaseBranchPatterns = [/master/, /HEAD/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set + Set releaseBranchPatterns = [/master/, /HEAD/, /main/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set Set excludeBranchPatterns = [] as Set String shortenedBranchPattern = /(?:(?:bugfix|feature|hotfix|release)(?:-|\/))?(.+)/ @@ -56,7 +56,7 @@ All tasks default to bumping the minor version. | Property | Type | Default | Description | | ----------------------- | ------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| releaseBranchPatterns | `Set` | `[master, HEAD, (release(-\|\/))?\d+(\.\d+)?\.x, v?\d+\.\d+\.\d+]` | Branch patterns that are acceptable to release from. The default pattern will match things like `master`, `1.2.x`, `release-42.x`, `release/2.x`, `v1.2.3`. If the set is empty releases will be possible from any branch that doesn't match `excludeBranchPatterns`. | +| releaseBranchPatterns | `Set` | `[master, HEAD, main, (release(-\|\/))?\d+(\.\d+)?\.x, v?\d+\.\d+\.\d+]` | Branch patterns that are acceptable to release from. The default pattern will match things like `master`, `1.2.x`, `release-42.x`, `release/2.x`, `v1.2.3`. If the set is empty releases will be possible from any branch that doesn't match `excludeBranchPatterns`. | | excludeBranchPatterns | `Set` | `[]` | Branch patterns that you cannot release from. If a branch matches both `releaseBranchPatterns` and `excludeBranchPatterns` it will be excluded. | | shortenedBranchPattern | `String` | `(?:(?:bugfix\|feature\|hotfix\|release)(?:-\|\/))?(.+)` | Branch `widget1` will append `widget1` to snapshot version numbers, and branch `(feature\|bugfix\|release\|hotfix)/widget2` will append `widget2` to snapshot version numbers. You may configure this field, the regex is expected to have exactly one capture group. | diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy index 386f32d..b0b173f 100644 --- a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIntegrationSpec.groovy @@ -521,7 +521,7 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { then: result.failure != null - outputContains(result, 'testexample does not match one of the included patterns: [master, HEAD, (release(-|/))?\\d+(\\.\\d+)?\\.x, v?\\d+\\.\\d+\\.\\d+]') + outputContains(result, 'testexample does not match one of the included patterns: [master, HEAD, main, (release(-|/))?\\d+(\\.\\d+)?\\.x, v?\\d+\\.\\d+\\.\\d+]') } def 'version includes branch name on devSnapshot of non release branch'() { @@ -1240,6 +1240,18 @@ class ReleasePluginIntegrationSpec extends GitVersioningIntegrationSpec { ] } + def 'final release using main branch'() { + git.checkout(branch: 'main', createBranch: true) + + when: + def result = runTasksSuccessfully('final') + + then: + result.wasExecuted('final') + result.standardOutput.contains('Tagging repository as v0.1.0') + result.standardOutput.contains('Pushing changes in [v0.1.0] to origin') + } + private void replaceDevWithImmutableSnapshot() { new File(buildFile.parentFile, "gradle.properties").text = """ nebula.release.features.replaceDevWithImmutableSnapshot=true diff --git a/src/main/groovy/nebula/plugin/release/ReleaseExtension.groovy b/src/main/groovy/nebula/plugin/release/ReleaseExtension.groovy index 3d112b7..6dc7d95 100644 --- a/src/main/groovy/nebula/plugin/release/ReleaseExtension.groovy +++ b/src/main/groovy/nebula/plugin/release/ReleaseExtension.groovy @@ -16,7 +16,7 @@ package nebula.plugin.release class ReleaseExtension { - Set releaseBranchPatterns = [/master/, /HEAD/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set + Set releaseBranchPatterns = [/master/, /HEAD/, /main/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set Set excludeBranchPatterns = [] as Set /**