Skip to content

Commit

Permalink
set "VERSION_WITH_BRANCH" versionCreator as default (#772)
Browse files Browse the repository at this point in the history
* set "VERSION_WITH_BRANCH" versionCreator as default

* Update version.md
  • Loading branch information
bgalek authored Jul 5, 2024
1 parent 7f17bfc commit c4b95c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
44 changes: 23 additions & 21 deletions docs/configuration/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ it's set to `v/.+`):

### incrementPrerelease

This rule uses additional parameter `initialPreReleaseIfNotOnPrerelease` (by default
it's empty):
This rule uses additional parameter `initialPreReleaseIfNotOnPrerelease`
(by default it's empty):

scmVersion {
versionIncrementer('incrementPrerelease', [initialPreReleaseIfNotOnPrerelease: 'rc1'])
Expand All @@ -265,15 +265,15 @@ it's empty):
## Decorating

Decorating phase happens only when version is read (and deserialized).
During this phase version can be decorated with i.e. branch name.
Default decorator does nothing. `axion-release-plugin` supports adding
predefined named version creators (so don't be afraid to post pull
request if you have something useful!). Decoration phase is conducted by
*version creators*, you can configure it via `scmVersion.versionCreator`
During this phase, the version will be decorated with a branch name (default behavior).
`axion-release-plugin` supports adding predefined named version creators
(so don't be afraid to post pull request if you have something useful!).
Decoration phase is conducted by *version creators*,
you can configure it via `scmVersion.versionCreator`
method:

scmVersion {
versionCreator('versionWithBranch')
versionCreator('versionWithCommitHash')
}

Or via `release.versionCreator` command line argument, which overrides
Expand All @@ -295,9 +295,23 @@ Per-branch version creators must be closures, there is no support for
predefined creators. First match wins, but the order depends on
collection type used (default for `[:]` is LinkedHashMap).

#### versionWithBranch [default]

scmVersion {
versionCreator('versionWithBranch')
}

This version creator appends branch name to version unless you are on
*main*/*master* or *detached HEAD*:

decorate(version: '0.1.0', branch: 'master') == 0.1.0
decorate(version: '0.1.0', branch: 'my-special-branch') == 0.1.0-my-special-branch

This is the default version creator since version 1.18.0 of the plugin.

#### simple

This is the default version creator that does nothing:
This version creator is no operation one:

decorate(version: '0.1.0') == 0.1.0

Expand All @@ -310,18 +324,6 @@ It might be useful when you want some branches to do *nothing*:
])
}

#### versionWithBranch

scmVersion {
versionCreator('versionWithBranch')
}

This version creator appends branch name to version unless you are on
*main*/*master* or *detached HEAD*:

decorate(version: '0.1.0', branch: 'master') == 0.1.0
decorate(version: '0.1.0', branch: 'my-special-branch') == 0.1.0-my-special-branch

#### versionWithCommitHash

scmVersion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.function.BiFunction
enum PredefinedVersionCreator {

SIMPLE('simple', { String versionFromTag, ScmPosition position ->
return versionFromTag.toString()
return versionFromTag
}),

VERSION_WITH_BRANCH('versionWithBranch', { String versionFromTag, ScmPosition position ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class VersionConfig extends BaseExtension {
getReleaseBranchPattern().convention(Pattern.compile('^' + defaultPrefix() + '(/.*)?$'))
getSanitizeVersion().convention(true)
getCreateReleaseCommit().convention(false)
getVersionCreator().convention(PredefinedVersionCreator.SIMPLE.versionCreator)
getVersionCreator().convention(PredefinedVersionCreator.VERSION_WITH_BRANCH.versionCreator)
getVersionIncrementer().convention((VersionProperties.Incrementer) { VersionIncrementerContext context -> return context.currentVersion.incrementPatchVersion() })
getSnapshotCreator().convention(PredefinedSnapshotCreator.SIMPLE.snapshotCreator)
getReleaseCommitMessage().convention(PredefinedReleaseCommitMessageCreator.DEFAULT.commitMessageCreator)
Expand Down

0 comments on commit c4b95c7

Please sign in to comment.