From 0f580cd4d12411346be5c5de801207c847457099 Mon Sep 17 00:00:00 2001 From: Janos Gyerik Date: Mon, 4 Feb 2019 07:45:47 +0100 Subject: [PATCH] SONAR-11683 Do not resolve version for SLB and PR --- .../task/projectanalysis/step/LoadPeriodsStep.java | 2 +- .../projectanalysis/step/LoadPeriodsStepTest.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java index 1b0d7b0fdba..b8cc247a6c1 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java @@ -100,7 +100,7 @@ public class LoadPeriodsStep implements ComputationStep { @Override public void execute(ComputationStep.Context context) { - if (analysisMetadataHolder.isFirstAnalysis()) { + if (analysisMetadataHolder.isFirstAnalysis() || !analysisMetadataHolder.isLongLivingBranch()) { periodsHolder.setPeriod(null); return; } diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java index 5b0eae50ef0..a0cd375b0a8 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java @@ -112,6 +112,7 @@ public class LoadPeriodsStepTest extends BaseStepTest { @Before public void setUp() throws Exception { november30th2008 = DATE_FORMAT.parse("2008-11-30"); + when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(true); } @Test @@ -845,6 +846,17 @@ public class LoadPeriodsStepTest extends BaseStepTest { verifyDebugLogs("Resolving new code period by version: 0.9"); } + @Test + @UseDataProvider("anyValidLeakPeriodSettingValue") + public void leak_period_setting_is_ignored_for_SLB_or_PR(String leakPeriodSettingValue) { + when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(false); + + settings.setProperty("sonar.leak.period", leakPeriodSettingValue); + underTest.execute(new TestComputationStepContext()); + + assertThat(periodsHolder.hasPeriod()).isFalse(); + } + private void assertPeriod(String mode, @Nullable String modeParameter, long snapshotDate, String analysisUuid) { Period period = periodsHolder.getPeriod(); assertThat(period).isNotNull(); -- 2.39.5