From 40d70b40fa254c184f5fa3b6aa440b6e8f226d87 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Thu, 23 Aug 2018 15:06:46 +0200 Subject: [PATCH] cleanup --- .../gradle/VersionCollection.groovy | 16 ++++------------ .../gradle/VersionCollectionTests.groovy | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy index 52fb1c7c8e1d1..daab0efc8c69a 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/VersionCollection.groovy @@ -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, @@ -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 @@ -298,10 +293,7 @@ class VersionCollection { */ private Version getHighestPreviousMinor(Integer nextMajorVersion) { SortedSet result = versionSet.headSet(Version.fromString("${nextMajorVersion}.0.0")) - if (result.isEmpty()) { - return null - } - return result.last() + return result.isEmpty() ? null : result.last() } /** diff --git a/buildSrc/src/test/groovy/org/elasticsearch/gradle/VersionCollectionTests.groovy b/buildSrc/src/test/groovy/org/elasticsearch/gradle/VersionCollectionTests.groovy index ad36c84078398..f6b9cb5fc95bf 100644 --- a/buildSrc/src/test/groovy/org/elasticsearch/gradle/VersionCollectionTests.groovy +++ b/buildSrc/src/test/groovy/org/elasticsearch/gradle/VersionCollectionTests.groovy @@ -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) @@ -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)