]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11683 Do not resolve version for SLB and PR
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Mon, 4 Feb 2019 06:45:47 +0000 (07:45 +0100)
committerSonarTech <sonartech@sonarsource.com>
Wed, 13 Feb 2019 19:20:54 +0000 (20:20 +0100)
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java

index 1b0d7b0fdba2c6d2155061cf8f9817efcabab116..b8cc247a6c13e09351626106dd53e07055eea917 100644 (file)
@@ -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;
     }
index 5b0eae50ef0a9db99d8ef4515182750d390c94b8..a0cd375b0a8b2f21f6e5c852cf0879dffdca0b35 100644 (file)
@@ -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();