]> source.dussan.org Git - sonarqube.git/commitdiff
Drop ScmBranchProvider (blend it into ScmProvider)
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Fri, 22 Sep 2017 15:15:31 +0000 (17:15 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 28 Sep 2017 07:14:43 +0000 (09:14 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmBranchProvider.java [deleted file]
sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmProvider.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java

diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmBranchProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/scm/ScmBranchProvider.java
deleted file mode 100644 (file)
index 1cb4c47..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-
-package org.sonar.api.batch.scm;
-
-import java.nio.file.Path;
-import java.util.Set;
-import javax.annotation.Nullable;
-import org.sonar.api.ExtensionPoint;
-import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.batch.ScannerSide;
-
-/**
- * A {@link ScmProvider} with the capability of finding out which files were changed in a branch.
- * @since 6.6
- */
-@ScannerSide
-@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-@ExtensionPoint
-public abstract class ScmBranchProvider extends ScmProvider {
-
-  /**
-   * Return absolute path of the files changed in the current branch, compared to the provided target branch.
-   * @return null if SCM provider was not able to compute the list of files.
-   */
-  @Nullable
-  public Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir) {
-    return null;
-  }
-}
index dd23c59d8ab4b5a2874d1d02165fbd27eaa0115e..e73d05a06cd4ef38bc09d58cab8c750c5eb3fd88 100644 (file)
  */
 package org.sonar.api.batch.scm;
 
-import org.sonar.api.batch.ScannerSide;
+import java.io.File;
+import java.nio.file.Path;
+import java.util.Set;
+import javax.annotation.Nullable;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.ExtensionPoint;
 import org.sonar.api.batch.InstantiationStrategy;
-
-import java.io.File;
+import org.sonar.api.batch.ScannerSide;
 
 /**
  * See {@link CoreProperties#LINKS_SOURCES_DEV} to get old Maven URL format.
@@ -54,4 +56,12 @@ public abstract class ScmProvider {
     throw new UnsupportedOperationException("Blame command is not supported by " + key() + " provider");
   }
 
+  /**
+   * Return absolute path of the files changed in the current branch, compared to the provided target branch.
+   * @return null if SCM provider was not able to compute the list of files.
+   */
+  @Nullable
+  public Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir) {
+    return null;
+  }
 }
index aed26e031440f74c165937b84764c78dfd115512..a3f6737fa6250a5e5d23ca6e50d268786a8eed45 100644 (file)
@@ -25,7 +25,6 @@ import javax.annotation.CheckForNull;
 import org.picocontainer.annotations.Nullable;
 import org.picocontainer.injectors.ProviderAdapter;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
-import org.sonar.api.batch.scm.ScmBranchProvider;
 import org.sonar.api.batch.scm.ScmProvider;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
@@ -65,10 +64,9 @@ public class ScmChangedFilesProvider extends ProviderAdapter {
   private static Collection<Path> loadChangedFilesIfNeeded(ScmConfiguration scmConfiguration, BranchConfiguration branchConfiguration, Path rootBaseDir) {
     if (branchConfiguration.isShortLivingBranch()) {
       ScmProvider scmProvider = scmConfiguration.provider();
-      if (scmProvider != null && (scmProvider instanceof ScmBranchProvider)) {
+      if (scmProvider != null) {
         Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
-        ScmBranchProvider scmBranchProvider = (ScmBranchProvider) scmProvider;
-        Collection<Path> changedFiles = scmBranchProvider.branchChangedFiles(branchConfiguration.branchTarget(), rootBaseDir);
+        Collection<Path> changedFiles = scmProvider.branchChangedFiles(branchConfiguration.branchTarget(), rootBaseDir);
         profiler.stopInfo();
         if (changedFiles != null) {
           LOG.debug("SCM reported {} {} changed in the branch", changedFiles.size(), pluralize("file", changedFiles.size()));
index bf278fee6cef419a4a9113607c94a71a10343b4a..eca414226bb5f994bcd19fd75b9b54847034fb76 100644 (file)
@@ -30,7 +30,6 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.batch.fs.internal.InputModuleHierarchy;
-import org.sonar.api.batch.scm.ScmBranchProvider;
 import org.sonar.api.batch.scm.ScmProvider;
 import org.sonar.scanner.scan.branch.BranchConfiguration;
 
@@ -48,7 +47,7 @@ public class ScmChangedFilesProviderTest {
   @Mock
   private InputModuleHierarchy inputModuleHierarchy;
   @Mock
-  private ScmBranchProvider scmProvider;
+  private ScmProvider scmProvider;
 
   @Rule
   public ExpectedException exception = ExpectedException.none();
@@ -109,7 +108,13 @@ public class ScmChangedFilesProviderTest {
 
   @Test
   public void testLegacyScmProvider() {
-    ScmProvider legacy = mock(ScmProvider.class);
+    ScmProvider legacy = new ScmProvider() {
+      @Override
+      public String key() {
+        return null;
+      }
+    };
+
     when(scmConfiguration.provider()).thenReturn(legacy);
     when(branchConfiguration.isShortLivingBranch()).thenReturn(true);
 
@@ -117,7 +122,6 @@ public class ScmChangedFilesProviderTest {
 
     assertThat(scmChangedFiles.get()).isNull();
     verify(scmConfiguration).provider();
-    verifyZeroInteractions(legacy);
   }
 
   @Test