Skip to content

Commit

Permalink
Merge pull request #197 from nebula-plugins/support-main-branch
Browse files Browse the repository at this point in the history
Support for main branch
  • Loading branch information
rpalcolea authored Sep 15, 2020
2 parents 08afea7 + 0bcde7e commit 0c349e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ All tasks default to bumping the minor version.

# Extension Provided
nebulaRelease {
Set<String> releaseBranchPatterns = [/master/, /HEAD/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set
Set<String> releaseBranchPatterns = [/master/, /HEAD/, /main/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set
Set<String> excludeBranchPatterns = [] as Set
String shortenedBranchPattern = /(?:(?:bugfix|feature|hotfix|release)(?:-|\/))?(.+)/

Expand All @@ -56,7 +56,7 @@ All tasks default to bumping the minor version.

| Property | Type | Default | Description |
| ----------------------- | ------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| releaseBranchPatterns | `Set<String>` | `[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<String>` | `[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<String>` | `[]` | 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. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'() {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package nebula.plugin.release

class ReleaseExtension {
Set<String> releaseBranchPatterns = [/master/, /HEAD/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set<String>
Set<String> releaseBranchPatterns = [/master/, /HEAD/, /main/, /(release(-|\/))?\d+(\.\d+)?\.x/, /v?\d+\.\d+\.\d+/] as Set<String>
Set<String> excludeBranchPatterns = [] as Set<String>

/**
Expand Down

0 comments on commit 0c349e1

Please sign in to comment.