001/*
002 * SonarQube
003 * Copyright (C) 2009-2017 SonarSource SA
004 * mailto:info AT sonarsource DOT com
005 *
006 * This program is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020package org.sonar.api.batch.scm;
021
022import java.io.File;
023import java.nio.file.Path;
024import java.util.Set;
025import javax.annotation.Nullable;
026import org.sonar.api.CoreProperties;
027import org.sonar.api.ExtensionPoint;
028import org.sonar.api.batch.InstantiationStrategy;
029import org.sonar.api.batch.ScannerSide;
030
031/**
032 * See {@link CoreProperties#LINKS_SOURCES_DEV} to get old Maven URL format.
033 * @since 5.0
034 */
035@ScannerSide
036@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
037@ExtensionPoint
038public abstract class ScmProvider {
039
040  /**
041   * Unique identifier of the provider. Can be passed to {@link CoreProperties#SCM_PROVIDER_KEY}
042   * Can be used in SCM URL to define the provider to use.
043   */
044  public abstract String key();
045
046  /**
047   * Whether this provider is able to manage files located in this directory.
048   * Used by autodetection. Not considered if user has forced the provider key.
049   * @return false by default
050   */
051  public boolean supports(File baseDir) {
052    return false;
053  }
054
055  public BlameCommand blameCommand() {
056    throw new UnsupportedOperationException("Blame command is not supported by " + key() + " provider");
057  }
058
059  /**
060   * Return absolute path of the files changed in the current branch, compared to the provided target branch.
061   * @return null if SCM provider was not able to compute the list of files.
062   */
063  @Nullable
064  public Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir) {
065    return null;
066  }
067}