GitScmProvider extends ScmProvider { @Override public boolean supports(File baseDir) { RepositoryBuilder builder = new RepositoryBuilder().findGitDir(baseDir); return builder.getGitDir() != null; } GitScmProvider(JGitBlameCommand jgitBlameCommand, AnalysisWarnings analysisWarnings, GitIgnoreCommand gitIgnoreCommand, System2 system2); @Override GitIgnoreCommand ignoreCommand(); @Override String key(); @Override boolean supports(File baseDir); @Override BlameCommand blameCommand(); @CheckForNull @Override Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir); @CheckForNull @Override Map<Path, Set<Integer>> branchChangedLines(String targetBranchName, Path projectBaseDir, Set<Path> changedFiles); @CheckForNull Instant forkDate(String referenceBranchName, Path projectBaseDir); @Override Path relativePathFromScmRoot(Path path); @Override @CheckForNull String revisionId(Path path);  }
@Test public void testAutodetection() throws IOException { File baseDirEmpty = temp.newFolder(); assertThat(newGitScmProvider().supports(baseDirEmpty)).isFalse(); File projectDir = temp.newFolder(); javaUnzip(new File("test-repos/dummy-git.zip"), projectDir); File baseDir = new File(projectDir, "dummy-git"); assertThat(newScmProvider().supports(baseDir)).isTrue(); }