diff --git a/src/main/java/org/springframework/data/release/git/GitOperations.java b/src/main/java/org/springframework/data/release/git/GitOperations.java index 6968fa7f..ac1918df 100644 --- a/src/main/java/org/springframework/data/release/git/GitOperations.java +++ b/src/main/java/org/springframework/data/release/git/GitOperations.java @@ -436,7 +436,7 @@ public TrainIteration getPreviousIteration(TrainIteration trainIteration) { Assert.notNull(trainIteration, "TrainIteration must not be null!"); - if (trainIteration.getIteration().isMilestone() && trainIteration.getIteration().getIterationValue() == 1) { + if (isGaOrFirstMilestone(trainIteration.getIteration())) { Train trainToUse = getPreviousTrain(trainIteration); return trainToUse.getIteration(Iteration.GA); @@ -546,6 +546,10 @@ private static Train getPreviousTrain(TrainIteration trainIteration) { return trainToUse; } + private static boolean isGaOrFirstMilestone(Iteration iteration) { + return iteration.isGAIteration() || (iteration.isMilestone() && iteration.getIterationValue() == 1); + } + private Stream getRemoteBranches(Project project) { return doWithGit(project, git -> { diff --git a/src/test/java/org/springframework/data/release/git/GitOperationsIntegrationTests.java b/src/test/java/org/springframework/data/release/git/GitOperationsIntegrationTests.java index 535304f6..867d3cd6 100644 --- a/src/test/java/org/springframework/data/release/git/GitOperationsIntegrationTests.java +++ b/src/test/java/org/springframework/data/release/git/GitOperationsIntegrationTests.java @@ -84,8 +84,8 @@ void shouldDeterminePreviousIterationFromGA() throws Exception { TrainIteration hopperRc1 = gitOperations.getPreviousIteration(ReleaseTrains.HOPPER.getIteration(Iteration.GA)); - assertThat(hopperRc1.getTrain()).isEqualTo(ReleaseTrains.HOPPER); - assertThat(hopperRc1.getIteration()).isEqualTo(Iteration.RC1); + assertThat(hopperRc1.getTrain()).isEqualTo(ReleaseTrains.GOSLING); + assertThat(hopperRc1.getIteration()).isEqualTo(Iteration.GA); TrainIteration hopperM1 = gitOperations.getPreviousIteration(ReleaseTrains.HOPPER.getIteration(Iteration.RC1));