Skip to content

Commit c4b95c7

Browse files
authored
set "VERSION_WITH_BRANCH" versionCreator as default (#772)
* set "VERSION_WITH_BRANCH" versionCreator as default * Update version.md
1 parent 7f17bfc commit c4b95c7

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

docs/configuration/version.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ it's set to `v/.+`):
255255

256256
### incrementPrerelease
257257

258-
This rule uses additional parameter `initialPreReleaseIfNotOnPrerelease` (by default
259-
it's empty):
258+
This rule uses additional parameter `initialPreReleaseIfNotOnPrerelease`
259+
(by default it's empty):
260260

261261
scmVersion {
262262
versionIncrementer('incrementPrerelease', [initialPreReleaseIfNotOnPrerelease: 'rc1'])
@@ -265,15 +265,15 @@ it's empty):
265265
## Decorating
266266

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

275275
scmVersion {
276-
versionCreator('versionWithBranch')
276+
versionCreator('versionWithCommitHash')
277277
}
278278

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

298+
#### versionWithBranch [default]
299+
300+
scmVersion {
301+
versionCreator('versionWithBranch')
302+
}
303+
304+
This version creator appends branch name to version unless you are on
305+
*main*/*master* or *detached HEAD*:
306+
307+
decorate(version: '0.1.0', branch: 'master') == 0.1.0
308+
decorate(version: '0.1.0', branch: 'my-special-branch') == 0.1.0-my-special-branch
309+
310+
This is the default version creator since version 1.18.0 of the plugin.
311+
298312
#### simple
299313

300-
This is the default version creator that does nothing:
314+
This version creator is no operation one:
301315

302316
decorate(version: '0.1.0') == 0.1.0
303317

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

313-
#### versionWithBranch
314-
315-
scmVersion {
316-
versionCreator('versionWithBranch')
317-
}
318-
319-
This version creator appends branch name to version unless you are on
320-
*main*/*master* or *detached HEAD*:
321-
322-
decorate(version: '0.1.0', branch: 'master') == 0.1.0
323-
decorate(version: '0.1.0', branch: 'my-special-branch') == 0.1.0-my-special-branch
324-
325327
#### versionWithCommitHash
326328

327329
scmVersion {

src/main/groovy/pl/allegro/tech/build/axion/release/domain/PredefinedVersionCreator.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.util.function.BiFunction
88
enum PredefinedVersionCreator {
99

1010
SIMPLE('simple', { String versionFromTag, ScmPosition position ->
11-
return versionFromTag.toString()
11+
return versionFromTag
1212
}),
1313

1414
VERSION_WITH_BRANCH('versionWithBranch', { String versionFromTag, ScmPosition position ->

src/main/groovy/pl/allegro/tech/build/axion/release/domain/VersionConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class VersionConfig extends BaseExtension {
4343
getReleaseBranchPattern().convention(Pattern.compile('^' + defaultPrefix() + '(/.*)?$'))
4444
getSanitizeVersion().convention(true)
4545
getCreateReleaseCommit().convention(false)
46-
getVersionCreator().convention(PredefinedVersionCreator.SIMPLE.versionCreator)
46+
getVersionCreator().convention(PredefinedVersionCreator.VERSION_WITH_BRANCH.versionCreator)
4747
getVersionIncrementer().convention((VersionProperties.Incrementer) { VersionIncrementerContext context -> return context.currentVersion.incrementPatchVersion() })
4848
getSnapshotCreator().convention(PredefinedSnapshotCreator.SIMPLE.snapshotCreator)
4949
getReleaseCommitMessage().convention(PredefinedReleaseCommitMessageCreator.DEFAULT.commitMessageCreator)

0 commit comments

Comments
 (0)