Skip to content

Commit

Permalink
Allow pre-release versions on tagged final
Browse files Browse the repository at this point in the history
If the current version is a final version, we previously did not allow
you to do anything besides rebuild as the current version or increment
to another final version.

While this isn't a recommended option, some people want to be able to
release pre-releases from the same commit that was already released.

There isn't anything critical in reckon depending on preventing this
kind of release, so it seems OK to allow.
  • Loading branch information
ajoberstar committed Jun 3, 2019
1 parent 692649e commit e71521a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ public Version reckon() {
throw new IllegalStateException("Reckoned version " + reckoned + " is (and cannot be) less than base version " + inventory.getBaseVersion());
}

inventory.getCurrentVersion().ifPresent(current -> {
if (inventory.isClean() && current.isFinal() && !reckoned.isFinal()) {
throw new IllegalStateException("Cannot re-release a final version " + current + " as a pre-release: " + reckoned);
}
});

return reckoned;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ReckonerTest extends Specification {
reckonSnapshot(inventory, 'major', 'final') == '2.0.0'
}

def 'if current version is present and normal, repo is clean, not allowed to release an incremented pre-release stage'() {
def 'if current version is present and normal, repo is clean, allowed to release an incremented pre-release stage'() {
given:
VcsInventory inventory = new VcsInventory(
'abcdef',
Expand All @@ -175,28 +175,9 @@ class ReckonerTest extends Specification {
[] as Set,
[Version.valueOf('1.2.2'), Version.valueOf('1.2.3')] as Set
)
when:
reckonStage(inventory, null, 'rc')
then:
thrown(IllegalStateException)
}

def 'if current version is present and normal, repo is clean, not allowed to release an incremented snapshot'() {
given:
VcsInventory inventory = new VcsInventory(
'abcdef',
true,
Version.valueOf('1.2.3'),
Version.valueOf('1.2.3'),
Version.valueOf('1.2.3'),
1,
[] as Set,
[Version.valueOf('1.2.2'), Version.valueOf('1.2.3')] as Set
)
when:
reckonSnapshot(inventory, null, 'snapshot')
then:
thrown(IllegalStateException)
expect:
reckonStage(inventory, null, 'rc') == '1.3.0-rc.1'
reckonSnapshot(inventory, null, 'snapshot') == '1.3.0-SNAPSHOT'
}

def 'if current version is present and pre-release, repo is clean, allowed to release a higher normal pre-release'() {
Expand Down

0 comments on commit e71521a

Please sign in to comment.