Skip to content

Commit

Permalink
Add released major logic to version utils (elastic#28644)
Browse files Browse the repository at this point in the history
Version Utils did not previously have logic that removed the last majors
minor snapshot if there was a next bugfix and maintenance bugfix
release. This adds the logic and fixes some broken assumptions in tests
as well.

relates elastic#28505
  • Loading branch information
hub-cap authored Feb 13, 2018
1 parent 8d0f976 commit 920dff7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ static Tuple<List<Version>, List<Version>> resolveReleasedVersions(Version curre
}

return new Tuple<>(unmodifiableList(versions), unmodifiableList(Arrays.asList(earlierUnreleased, unreleased, current)));
} else if (unreleased.major == current.major) {
// need to remove one more of the last major's minor set
do {
unreleasedIndex--;
} while (unreleasedIndex > 0 && versions.get(unreleasedIndex).major == current.major);
if (unreleasedIndex > 0) {
// some of the test cases return very small lists, so its possible this is just the end of the list, if so, dont include it
Version earlierMajorsMinor = versions.remove(unreleasedIndex);
return new Tuple<>(unmodifiableList(versions), unmodifiableList(Arrays.asList(earlierMajorsMinor, unreleased, current)));
}
}
return new Tuple<>(unmodifiableList(versions), unmodifiableList(Arrays.asList(unreleased, current)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ public void testResolveReleasedVersionsAtVersionBumpIn6x() {
assertThat(released, equalTo(Arrays.asList(
TestVersionBumpIn6x.V_5_6_0,
TestVersionBumpIn6x.V_5_6_1,
TestVersionBumpIn6x.V_5_6_2,
TestVersionBumpIn6x.V_6_0_0_alpha1,
TestVersionBumpIn6x.V_6_0_0_alpha2,
TestVersionBumpIn6x.V_6_0_0_beta1,
TestVersionBumpIn6x.V_6_0_0_beta2,
TestVersionBumpIn6x.V_6_0_0)));
assertThat(unreleased, equalTo(Arrays.asList(
TestVersionBumpIn6x.V_5_6_2,
TestVersionBumpIn6x.V_6_0_1,
TestVersionBumpIn6x.V_6_1_0)));
}
Expand Down Expand Up @@ -291,7 +291,6 @@ public void testResolveReleasedVersionsAtNewMinorBranchIn6x() {
assertThat(released, equalTo(Arrays.asList(
TestNewMinorBranchIn6x.V_5_6_0,
TestNewMinorBranchIn6x.V_5_6_1,
TestNewMinorBranchIn6x.V_5_6_2,
TestNewMinorBranchIn6x.V_6_0_0_alpha1,
TestNewMinorBranchIn6x.V_6_0_0_alpha2,
TestNewMinorBranchIn6x.V_6_0_0_beta1,
Expand All @@ -301,6 +300,7 @@ public void testResolveReleasedVersionsAtNewMinorBranchIn6x() {
TestNewMinorBranchIn6x.V_6_1_0,
TestNewMinorBranchIn6x.V_6_1_1)));
assertThat(unreleased, equalTo(Arrays.asList(
TestNewMinorBranchIn6x.V_5_6_2,
TestNewMinorBranchIn6x.V_6_1_2,
TestNewMinorBranchIn6x.V_6_2_0)));
}
Expand Down

0 comments on commit 920dff7

Please sign in to comment.