Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Aug 23, 2018
1 parent fac4e45 commit 40d70b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class VersionCollection {
} else {
// caveat 3 - if our currentVersion is a X.0.0, we need to check X-1 minors to see if they are released
if (currentVersion.minor == 0) {
for (Version version : getMinorTips(currentVersion.major - 1)) {
for (Version version: getMinorTips(currentVersion.major - 1)) {
if (isReleased(version) == false) {
// caveat 1 - This should only ever contain 2 non released branches in flight. An example is 6.x is frozen,
// and 6.2 is cut but not yet released there is some simple logic to make sure that in the case of more than 2,
Expand All @@ -138,13 +138,8 @@ class VersionCollection {
break
}
}
// caveat 0 - now dip back 2 versions to get the last supported snapshot version of the line
Version highestMinor = getHighestPreviousMinor(currentVersion.major - 1)
if (highestMinor == null) {
maintenanceBugfixSnapshot = null
} else {
maintenanceBugfixSnapshot = replaceAsSnapshot(highestMinor)
}
// caveat 0 - the last supported snapshot of the line is on a version that we don't support (N-2)
maintenanceBugfixSnapshot = null
} else {
// caveat 3 did not apply. version is not a X.0.0, so we are somewhere on a X.Y line
// only check till minor == 0 of the major
Expand Down Expand Up @@ -298,10 +293,7 @@ class VersionCollection {
*/
private Version getHighestPreviousMinor(Integer nextMajorVersion) {
SortedSet<Version> result = versionSet.headSet(Version.fromString("${nextMajorVersion}.0.0"))
if (result.isEmpty()) {
return null
}
return result.last()
return result.isEmpty() ? null : result.last()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VersionCollectionTests extends GradleUnitTestCase {
assertEquals(vc.nextMinorSnapshot, Version.fromString("6.3.0-SNAPSHOT"))
assertEquals(vc.stagedMinorSnapshot, Version.fromString("6.2.0-SNAPSHOT"))
assertEquals(vc.nextBugfixSnapshot, Version.fromString("6.1.1-SNAPSHOT"))
assertEquals(vc.maintenanceBugfixSnapshot, Version.fromString("5.2.1-SNAPSHOT"))
assertNull(vc.maintenanceBugfixSnapshot)

vc.indexCompatible.containsAll(vc.versions)

Expand Down Expand Up @@ -65,7 +65,7 @@ class VersionCollectionTests extends GradleUnitTestCase {
assertEquals(vc.nextMinorSnapshot, Version.fromString("6.3.0-SNAPSHOT"))
assertEquals(vc.stagedMinorSnapshot, null)
assertEquals(vc.nextBugfixSnapshot, Version.fromString("6.2.1-SNAPSHOT"))
assertEquals(vc.maintenanceBugfixSnapshot, Version.fromString("5.2.1-SNAPSHOT"))
assertNull(vc.maintenanceBugfixSnapshot)

vc.indexCompatible.containsAll(vc.versions)

Expand Down

0 comments on commit 40d70b4

Please sign in to comment.