Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PredefinedSnapshotCreator: unclean snapshot #544

Merged
merged 5 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
}
}