+++ /dev/null
-/*
- * 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;
- }
-}
*/
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.
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;
+ }
}
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;
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()));
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;
@Mock
private InputModuleHierarchy inputModuleHierarchy;
@Mock
- private ScmBranchProvider scmProvider;
+ private ScmProvider scmProvider;
@Rule
public ExpectedException exception = ExpectedException.none();
@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);
assertThat(scmChangedFiles.get()).isNull();
verify(scmConfiguration).provider();
- verifyZeroInteractions(legacy);
}
@Test