diff options
author | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-22 17:15:31 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-09-28 09:14:43 +0200 |
commit | 3dec1d76c61bb37e5fbc2394cae766c02dcf8a9d (patch) | |
tree | c8d6923ae76c2aea98f6a3dfb4ab90e2737a724a /sonar-scanner-engine | |
parent | 5abe7f209af3621d1bd94ef15c9d43e93a056200 (diff) | |
download | sonarqube-3dec1d76c61bb37e5fbc2394cae766c02dcf8a9d.tar.gz sonarqube-3dec1d76c61bb37e5fbc2394cae766c02dcf8a9d.zip |
Drop ScmBranchProvider (blend it into ScmProvider)
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java | 6 | ||||
-rw-r--r-- | sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java index aed26e03144..a3f6737fa62 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmChangedFilesProvider.java @@ -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())); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java index bf278fee6ce..eca414226bb 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java @@ -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 |