Skip to content

Commit

Permalink
PredefinedSnapshotCreator: unclean snapshot (#544)
Browse files Browse the repository at this point in the history
* ScmPosition: added isClean

* PredefinedSnapshotCreator: -unclean-SNAPSHOT

* added @input to new method getIsClean()
  • Loading branch information
mkoester committed Jul 28, 2023
1 parent 47b2c47 commit e733b2c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ enum PredefinedSnapshotCreator {
return "-SNAPSHOT";
}),

UNCLEAN('unclean', { String version, ScmPosition position ->
if (!position.isClean) {
return "-unclean-SNAPSHOT"
} else {
return "-SNAPSHOT";
};
}),

private final String type

final VersionProperties.Creator snapshotCreator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package pl.allegro.tech.build.axion.release.domain

import spock.lang.Specification

import static pl.allegro.tech.build.axion.release.domain.scm.ScmPositionBuilder.scmPosition

class PredefinedSnapshotCreatorTest extends Specification {

def "default snapshot creator should just return -SNAPSHOT"() {
expect:
PredefinedSnapshotCreator.SIMPLE.snapshotCreator.apply('version', scmPosition('master')) == '-SNAPSHOT'
}

def "unclean snapshot creator should just return -SNAPSHOT when scm is clean"() {
expect:
PredefinedSnapshotCreator.UNCLEAN.snapshotCreator.apply('version', scmPosition('master')) == '-SNAPSHOT'
}

def "unclean snapshot creator should return -unclean-SNAPSHOT when scm is NOT clean"() {
expect:
PredefinedSnapshotCreator.UNCLEAN.snapshotCreator.apply('version', scmPosition().withBranch('master').withUnclean().build()) == '-unclean-SNAPSHOT'
}
}

0 comments on commit e733b2c

Please sign in to comment.