aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-27 21:22:41 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-27 21:23:44 +0100
commit3dfb73b81c2f2c21b2b29a477da63fe7b0561b1f (patch)
tree3906fbfbf81b07f5479894a69f80b82003f9d9f3
parent27b714e7f3fbf40393d201bd0c63ab7afb764d90 (diff)
downloadsonarqube-3dfb73b81c2f2c21b2b29a477da63fe7b0561b1f.tar.gz
sonarqube-3dfb73b81c2f2c21b2b29a477da63fe7b0561b1f.zip
SONAR-6105 Extract SVN and Git as standalone plugins
-rw-r--r--plugins/sonar-git-plugin/pom.xml65
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java37
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java49
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java137
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/package-info.java25
-rw-r--r--plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java32
-rw-r--r--plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java63
-rw-r--r--plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/JGitBlameCommandTest.java259
-rw-r--r--plugins/sonar-git-plugin/test-repos/dummy-git-nested.zipbin60535 -> 0 bytes
-rw-r--r--plugins/sonar-git-plugin/test-repos/dummy-git.zipbin51878 -> 0 bytes
-rw-r--r--plugins/sonar-svn-plugin/pom.xml60
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameCommand.java158
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameConsumer.java159
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnConfiguration.java126
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnPlugin.java40
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnScmProvider.java49
-rw-r--r--plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/package-info.java25
-rw-r--r--plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnBlameCommandTest.java260
-rw-r--r--plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnPluginTest.java32
-rw-r--r--plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnScmProviderTest.java58
-rw-r--r--plugins/sonar-svn-plugin/src/test/resources/blame-with-anonymous-commit.xml29
-rw-r--r--plugins/sonar-svn-plugin/src/test/resources/blame-with-merge-history.xml54
-rw-r--r--plugins/sonar-svn-plugin/src/test/resources/blame-with-uncomitted-changes.xml25
-rw-r--r--plugins/sonar-svn-plugin/src/test/resources/blame.xml30
-rw-r--r--pom.xml12
-rw-r--r--sonar-application/pom.xml4
26 files changed, 8 insertions, 1780 deletions
diff --git a/plugins/sonar-git-plugin/pom.xml b/plugins/sonar-git-plugin/pom.xml
deleted file mode 100644
index 9916e21e6ea..00000000000
--- a/plugins/sonar-git-plugin/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar</artifactId>
- <version>5.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-scm-git-plugin</artifactId>
- <name>SonarQube :: Plugins :: SCM :: Git</name>
- <packaging>sonar-plugin</packaging>
- <description>Git SCM Provider.</description>
-
- <dependencies>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jgit</groupId>
- <artifactId>org.eclipse.jgit</artifactId>
- <version>3.5.0.201409260305-r</version>
- </dependency>
-
- <!-- unit tests -->
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <configuration>
- <pluginKey>git</pluginKey>
- <pluginName>Git</pluginName>
- <pluginClass>org.sonar.plugins.scm.git.GitPlugin</pluginClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java
deleted file mode 100644
index 7be985cb6e7..00000000000
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitPlugin.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.SonarPlugin;
-
-import java.util.List;
-
-public final class GitPlugin extends SonarPlugin {
-
- static final String CATEGORY_GIT = "Git";
-
- @Override
- public List getExtensions() {
- return ImmutableList.of(
- GitScmProvider.class,
- JGitBlameCommand.class);
- }
-}
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java
deleted file mode 100644
index a86543c2746..00000000000
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/GitScmProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import org.sonar.api.batch.scm.BlameCommand;
-import org.sonar.api.batch.scm.ScmProvider;
-
-import java.io.File;
-
-public class GitScmProvider extends ScmProvider {
-
- private final JGitBlameCommand jgitBlameCommand;
-
- public GitScmProvider(JGitBlameCommand jgitBlameCommand) {
- this.jgitBlameCommand = jgitBlameCommand;
- }
-
- @Override
- public String key() {
- return "git";
- }
-
- @Override
- public boolean supports(File baseDir) {
- return new File(baseDir, ".git").exists();
- }
-
- @Override
- public BlameCommand blameCommand() {
- return this.jgitBlameCommand;
- }
-}
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java
deleted file mode 100644
index 12acbfe55b0..00000000000
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.diff.RawTextComparator;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.lib.RepositoryBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.scm.BlameCommand;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.scan.filesystem.PathResolver;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-public class JGitBlameCommand extends BlameCommand {
-
- private static final Logger LOG = LoggerFactory.getLogger(JGitBlameCommand.class);
-
- private final PathResolver pathResolver;
-
- public JGitBlameCommand(PathResolver pathResolver) {
- this.pathResolver = pathResolver;
- }
-
- @Override
- public void blame(BlameInput input, BlameOutput output) {
- File basedir = input.fileSystem().baseDir();
- Repository repo = buildRepository(basedir);
- try {
- Git git = Git.wrap(repo);
- File gitBaseDir = repo.getWorkTree();
- ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
- List<Future<Void>> tasks = submitTasks(input, output, git, gitBaseDir, executorService);
- waitForTaskToComplete(tasks);
- } finally {
- repo.close();
- }
- }
-
- private void waitForTaskToComplete(List<Future<Void>> tasks) {
- for (Future<Void> task : tasks) {
- try {
- task.get();
- } catch (ExecutionException e) {
- // Unwrap ExecutionException
- throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new IllegalStateException(e.getCause());
- } catch (InterruptedException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- private List<Future<Void>> submitTasks(BlameInput input, BlameOutput output, Git git, File gitBaseDir, ExecutorService executorService) {
- List<Future<Void>> tasks = new ArrayList<Future<Void>>();
- for (InputFile inputFile : input.filesToBlame()) {
- tasks.add(submitTask(output, git, gitBaseDir, inputFile, executorService));
- }
- return tasks;
- }
-
- private Repository buildRepository(File basedir) {
- try {
- Repository repo = new RepositoryBuilder()
- .findGitDir(basedir)
- .setMustExist(true)
- .build();
- // SONAR-6064 Force initialization of shallow commits to avoid later concurrent modification issue
- repo.getObjectDatabase().newReader().getShallowCommits();
- return repo;
- } catch (IOException e) {
- throw new IllegalStateException("Unable to open Git repository", e);
- }
- }
-
- private Future<Void> submitTask(final BlameOutput output, final Git git, final File gitBaseDir, final InputFile inputFile, ExecutorService executorService) {
- return executorService.submit(new Callable<Void>() {
- @Override
- public Void call() throws GitAPIException {
- blame(output, git, gitBaseDir, inputFile);
- return null;
- }
- });
- }
-
- private void blame(BlameOutput output, Git git, File gitBaseDir, InputFile inputFile) throws GitAPIException {
- String filename = pathResolver.relativePath(gitBaseDir, inputFile.file());
- org.eclipse.jgit.blame.BlameResult blameResult = git.blame()
- // Equivalent to -w command line option
- .setTextComparator(RawTextComparator.WS_IGNORE_ALL)
- .setFilePath(filename).call();
- List<BlameLine> lines = new ArrayList<BlameLine>();
- for (int i = 0; i < blameResult.getResultContents().size(); i++) {
- if (blameResult.getSourceAuthor(i) == null || blameResult.getSourceCommit(i) == null) {
- LOG.info("Author: " + blameResult.getSourceAuthor(i));
- LOG.info("Source commit: " + blameResult.getSourceCommit(i));
- throw new IllegalStateException("Unable to blame file " + inputFile.relativePath() + ". No blame info at line " + (i + 1) + ". Is file commited?");
- }
- lines.add(new org.sonar.api.batch.scm.BlameLine().date(blameResult.getSourceAuthor(i).getWhen()).revision(blameResult.getSourceCommit(i).getName())
- .author(blameResult.getSourceAuthor(i).getEmailAddress()));
- }
- if (lines.size() == inputFile.lines() - 1) {
- // SONARPLUGINS-3097 Git do not report blame on last empty line
- lines.add(lines.get(lines.size() - 1));
- }
- output.blameResult(inputFile, lines);
- }
-
-}
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/package-info.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/package-info.java
deleted file mode 100644
index 748474dc689..00000000000
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.scm.git;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java
deleted file mode 100644
index caccdf6632e..00000000000
--- a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitPluginTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GitPluginTest {
-
- @Test
- public void getExtensions() {
- assertThat(new GitPlugin().getExtensions()).hasSize(2);
- }
-}
diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java
deleted file mode 100644
index 09a54b15499..00000000000
--- a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/GitScmProviderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.scan.filesystem.PathResolver;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class GitScmProviderTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void sanityCheck() {
- assertThat(new GitScmProvider(null).key()).isEqualTo("git");
- }
-
- @Test
- public void returnImplem() {
- JGitBlameCommand jblameCommand = new JGitBlameCommand(new PathResolver());
- GitScmProvider gitScmProvider = new GitScmProvider(jblameCommand);
-
- assertThat(gitScmProvider.blameCommand()).isEqualTo(jblameCommand);
- }
-
- @Test
- public void testAutodetection() throws IOException {
- File baseDirEmpty = temp.newFolder();
- assertThat(new GitScmProvider(null).supports(baseDirEmpty)).isFalse();
-
- File gitBaseDir = temp.newFolder();
- new File(gitBaseDir, ".git").mkdir();
- assertThat(new GitScmProvider(null).supports(gitBaseDir)).isTrue();
- }
-
-}
diff --git a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/JGitBlameCommandTest.java b/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/JGitBlameCommandTest.java
deleted file mode 100644
index 7f74bea84a9..00000000000
--- a/plugins/sonar-git-plugin/src/test/java/org/sonar/plugins/scm/git/JGitBlameCommandTest.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.git;
-
-import com.google.common.io.Closeables;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.scm.BlameCommand.BlameInput;
-import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.scan.filesystem.PathResolver;
-import org.sonar.api.utils.DateUtils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class JGitBlameCommandTest {
-
- private static final String DUMMY_JAVA = "src/main/java/org/dummy/Dummy.java";
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- private DefaultFileSystem fs;
- private BlameInput input;
-
- @Before
- public void prepare() throws IOException {
- fs = new DefaultFileSystem();
- input = mock(BlameInput.class);
- when(input.fileSystem()).thenReturn(fs);
- }
-
- @Test
- public void testBlame() throws IOException {
- File projectDir = temp.newFolder();
- javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
-
- JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
-
- File baseDir = new File(projectDir, "dummy-git");
- fs.setBaseDir(baseDir);
- DefaultInputFile inputFile = new DefaultInputFile("foo", DUMMY_JAVA)
- .setFile(new File(baseDir, DUMMY_JAVA));
- fs.add(inputFile);
-
- BlameOutput blameResult = mock(BlameOutput.class);
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
- jGitBlameCommand.blame(input, blameResult);
-
- Date revisionDate = DateUtils.parseDateTime("2012-07-17T16:12:48+0200");
- String revision = "6b3aab35a3ea32c1636fee56f996e677653c48ea";
- String author = "david@gageot.net";
- verify(blameResult).blameResult(inputFile,
- Arrays.asList(
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author)));
- }
-
- @Test
- public void testBlameOnNestedModule() throws IOException {
- File projectDir = temp.newFolder();
- javaUnzip(new File("test-repos/dummy-git-nested.zip"), projectDir);
-
- JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
-
- File baseDir = new File(projectDir, "dummy-git-nested/dummy-project");
- fs.setBaseDir(baseDir);
- DefaultInputFile inputFile = new DefaultInputFile("foo", DUMMY_JAVA)
- .setFile(new File(baseDir, DUMMY_JAVA));
- fs.add(inputFile);
-
- BlameOutput blameResult = mock(BlameOutput.class);
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
- jGitBlameCommand.blame(input, blameResult);
-
- Date revisionDate = DateUtils.parseDateTime("2012-07-17T16:12:48+0200");
- String revision = "6b3aab35a3ea32c1636fee56f996e677653c48ea";
- String author = "david@gageot.net";
- verify(blameResult).blameResult(inputFile,
- Arrays.asList(
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author),
- new BlameLine().revision(revision).date(revisionDate).author(author)));
- }
-
- @Test
- public void testBlameOnModifiedFile() throws IOException {
- File projectDir = temp.newFolder();
- javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
-
- JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
-
- File baseDir = new File(projectDir, "dummy-git");
- fs.setBaseDir(baseDir);
- String relativePath = DUMMY_JAVA;
- DefaultInputFile inputFile = new DefaultInputFile("foo", relativePath)
- .setFile(new File(baseDir, relativePath));
- fs.add(inputFile);
-
- // Emulate a modification
- FileUtils.write(new File(baseDir, relativePath), "modification and \n some new line", true);
-
- BlameOutput blameResult = mock(BlameOutput.class);
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Unable to blame file " + relativePath + ". No blame info at line 27. Is file commited?");
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
- jGitBlameCommand.blame(input, blameResult);
- }
-
- @Test
- public void testBlameOnNewFile() throws IOException {
- File projectDir = temp.newFolder();
- javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);
-
- JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());
-
- File baseDir = new File(projectDir, "dummy-git");
- fs.setBaseDir(baseDir);
- String relativePath = DUMMY_JAVA;
- String relativePath2 = "src/main/java/org/dummy/Dummy2.java";
- DefaultInputFile inputFile = new DefaultInputFile("foo", relativePath)
- .setFile(new File(baseDir, relativePath));
- fs.add(inputFile);
- DefaultInputFile inputFile2 = new DefaultInputFile("foo", relativePath2)
- .setFile(new File(baseDir, relativePath2));
- fs.add(inputFile2);
-
- // Emulate a new file
- FileUtils.copyFile(new File(baseDir, relativePath), new File(baseDir, relativePath2));
-
- BlameOutput blameResult = mock(BlameOutput.class);
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Unable to blame file " + relativePath2 + ". No blame info at line 1. Is file commited?");
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile, inputFile2));
- jGitBlameCommand.blame(input, blameResult);
- }
-
- private static void javaUnzip(File zip, File toDir) {
- try {
- ZipFile zipFile = new ZipFile(zip);
- try {
- Enumeration<? extends ZipEntry> entries = zipFile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = entries.nextElement();
- File to = new File(toDir, entry.getName());
- if (entry.isDirectory()) {
- FileUtils.forceMkdir(to);
- } else {
- File parent = to.getParentFile();
- if (parent != null) {
- FileUtils.forceMkdir(parent);
- }
-
- OutputStream fos = new FileOutputStream(to);
- try {
- IOUtils.copy(zipFile.getInputStream(entry), fos);
- } finally {
- Closeables.closeQuietly(fos);
- }
- }
- }
- } finally {
- zipFile.close();
- }
- } catch (Exception e) {
- throw new IllegalStateException("Fail to unzip " + zip + " to " + toDir, e);
- }
- }
-
-}
diff --git a/plugins/sonar-git-plugin/test-repos/dummy-git-nested.zip b/plugins/sonar-git-plugin/test-repos/dummy-git-nested.zip
deleted file mode 100644
index b0ee03b6b16..00000000000
--- a/plugins/sonar-git-plugin/test-repos/dummy-git-nested.zip
+++ /dev/null
Binary files differ
diff --git a/plugins/sonar-git-plugin/test-repos/dummy-git.zip b/plugins/sonar-git-plugin/test-repos/dummy-git.zip
deleted file mode 100644
index e019a80dee2..00000000000
--- a/plugins/sonar-git-plugin/test-repos/dummy-git.zip
+++ /dev/null
Binary files differ
diff --git a/plugins/sonar-svn-plugin/pom.xml b/plugins/sonar-svn-plugin/pom.xml
deleted file mode 100644
index 5b8acf5fbbe..00000000000
--- a/plugins/sonar-svn-plugin/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar</artifactId>
- <version>5.1-SNAPSHOT</version>
- <relativePath>../..</relativePath>
- </parent>
- <groupId>org.codehaus.sonar.plugins</groupId>
- <artifactId>sonar-scm-svn-plugin</artifactId>
- <name>SonarQube :: Plugins :: SCM :: SVN</name>
- <packaging>sonar-plugin</packaging>
- <description>SVN SCM Provider.</description>
-
- <dependencies>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-plugin-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- unit tests -->
- <dependency>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-testing-harness</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.sonar</groupId>
- <artifactId>sonar-packaging-maven-plugin</artifactId>
- <configuration>
- <pluginKey>svn</pluginKey>
- <pluginName>SVN</pluginName>
- <pluginClass>org.sonar.plugins.scm.svn.SvnPlugin</pluginClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameCommand.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameCommand.java
deleted file mode 100644
index f088967589a..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameCommand.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.scm.BlameCommand;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.utils.command.Command;
-import org.sonar.api.utils.command.CommandException;
-import org.sonar.api.utils.command.CommandExecutor;
-import org.sonar.api.utils.command.StreamConsumer;
-import org.sonar.api.utils.command.StringStreamConsumer;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-public class SvnBlameCommand extends BlameCommand {
-
- private static final Logger LOG = LoggerFactory.getLogger(SvnBlameCommand.class);
- private final CommandExecutor commandExecutor;
- private final SvnConfiguration configuration;
-
- public SvnBlameCommand(SvnConfiguration configuration) {
- this(CommandExecutor.create(), configuration);
- }
-
- SvnBlameCommand(CommandExecutor commandExecutor, SvnConfiguration configuration) {
- this.commandExecutor = commandExecutor;
- this.configuration = configuration;
- }
-
- @Override
- public void blame(final BlameInput input, final BlameOutput output) {
- FileSystem fs = input.fileSystem();
- LOG.debug("Working directory: " + fs.baseDir().getAbsolutePath());
- ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
- List<Future<Void>> tasks = new ArrayList<Future<Void>>();
- for (InputFile inputFile : input.filesToBlame()) {
- tasks.add(submitTask(fs, output, executorService, inputFile));
- }
-
- for (Future<Void> task : tasks) {
- try {
- task.get();
- } catch (ExecutionException e) {
- // Unwrap ExecutionException
- throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new IllegalStateException(e.getCause());
- } catch (InterruptedException e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- private Future<Void> submitTask(final FileSystem fs, final BlameOutput result, ExecutorService executorService, final InputFile inputFile) {
- return executorService.submit(new Callable<Void>() {
- @Override
- public Void call() {
- blame(fs, inputFile, result);
- return null;
- }
- });
- }
-
- private void blame(final FileSystem fs, final InputFile inputFile, final BlameOutput output) {
- String filename = inputFile.relativePath();
- Command cl = createCommandLine(fs.baseDir(), filename);
- SvnBlameConsumer consumer = new SvnBlameConsumer(filename);
- StringStreamConsumer stderr = new StringStreamConsumer();
- int exitCode;
- try {
- exitCode = execute(cl, consumer, stderr);
- } catch (CommandException e) {
- // Unwrap CommandException
- throw e.getCause() instanceof RuntimeException ? (RuntimeException) e.getCause() : new IllegalStateException(e.getCause());
- }
- if (exitCode != 0) {
- throw new IllegalStateException("The svn blame command [" + cl.toString() + "] failed: " + stderr.getOutput());
- }
- List<BlameLine> lines = consumer.getLines();
- if (lines.size() == inputFile.lines() - 1) {
- // SONARPLUGINS-3097 SVN do not report blame on last empty line
- lines.add(lines.get(lines.size() - 1));
- }
- output.blameResult(inputFile, lines);
- }
-
- private int execute(Command cl, StreamConsumer consumer, StreamConsumer stderr) {
- LOG.debug("Executing: " + cl);
- return commandExecutor.execute(cl, consumer, stderr, -1);
- }
-
- @VisibleForTesting
- Command createCommandLine(File baseDir, String filename) {
- Command cl = Command.create("svn");
- for (Entry<String, String> env : System.getenv().entrySet()) {
- cl.setEnvironmentVariable(env.getKey(), env.getValue());
- }
- cl.setEnvironmentVariable("LC_MESSAGES", "en");
-
- cl.setDirectory(baseDir);
- cl.addArgument("blame");
- cl.addArgument("--xml");
- if (configuration.useMergeHistory()) {
- cl.addArgument("--use-merge-history");
- }
- cl.addArgument("--non-interactive");
- cl.addArgument("-x");
- cl.addArgument("-w");
- String configDir = configuration.configDir();
- if (configDir != null) {
- cl.addArgument("--config-dir");
- cl.addArgument(configDir);
- }
- String username = configuration.username();
- if (username != null) {
- cl.addArgument("--username");
- cl.addMaskedArgument(username);
- String password = configuration.password();
- if (password != null) {
- cl.addArgument("--password");
- cl.addMaskedArgument(password);
- }
- }
- if (configuration.trustServerCert()) {
- cl.addArgument("--trust-server-cert");
- }
- cl.addArgument(filename);
- return cl;
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameConsumer.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameConsumer.java
deleted file mode 100644
index 3bf42c756b3..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnBlameConsumer.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.utils.command.StreamConsumer;
-
-import javax.annotation.CheckForNull;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class SvnBlameConsumer implements StreamConsumer {
-
- private static final Logger LOG = LoggerFactory.getLogger(SvnBlameConsumer.class);
-
- private static final String SVN_TIMESTAMP_PATTERN = "yyyy-MM-dd HH:mm:ss";
-
- private static final Pattern LINE_PATTERN = Pattern.compile("line-number=\"(.*)\"");
-
- private static final Pattern REVISION_PATTERN = Pattern.compile("revision=\"(.*)\"");
-
- private static final Pattern AUTHOR_PATTERN = Pattern.compile("<author>(.*)</author>");
-
- private static final Pattern DATE_PATTERN = Pattern.compile("<date>(.*)T(.*)\\.(.*)Z</date>");
-
- private boolean insideCommitSection = false;
- private boolean insideMergedSection = false;
-
- private SimpleDateFormat dateFormat;
-
- private List<BlameLine> lines = new ArrayList<BlameLine>();
-
- private final String filename;
-
- public SvnBlameConsumer(String filename) {
- this.filename = filename;
- dateFormat = new SimpleDateFormat(SVN_TIMESTAMP_PATTERN);
- dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- }
-
- private int lineNumber = 0;
-
- private String committerRevision;
- private String committer;
- private Date committerDate;
- private String authorRevision;
- private String author;
- private Date authorDate;
-
- @Override
- public void consumeLine(String line) {
- Matcher matcher;
- if ((matcher = LINE_PATTERN.matcher(line)).find()) {
- String lineNumberStr = matcher.group(1);
- lineNumber = Integer.parseInt(lineNumberStr);
- insideCommitSection = false;
- insideMergedSection = false;
- } else if (line.contains("<commit") && !insideMergedSection) {
- insideCommitSection = true;
- } else if (line.contains("<merged")) {
- insideMergedSection = true;
- insideCommitSection = false;
- } else if ((matcher = REVISION_PATTERN.matcher(line)).find()) {
- if (insideCommitSection) {
- committerRevision = matcher.group(1);
- } else if (insideMergedSection) {
- authorRevision = matcher.group(1);
- }
- } else if ((matcher = AUTHOR_PATTERN.matcher(line)).find()) {
- if (insideCommitSection) {
- committer = matcher.group(1);
- } else if (insideMergedSection) {
- author = matcher.group(1);
- }
- } else if ((matcher = DATE_PATTERN.matcher(line)).find()) {
- String date = matcher.group(1);
- String time = matcher.group(2);
- Date dateTime = parseDateTime(date + " " + time);
- if (insideCommitSection) {
- committerDate = dateTime;
- } else if (insideMergedSection) {
- authorDate = dateTime;
- }
- } else if (line.contains("</entry>")) {
- if (authorRevision != null) {
- lines.add(new BlameLine().revision(authorRevision).author(author).date(authorDate));
- } else if (committerRevision != null) {
- lines.add(new BlameLine().revision(committerRevision).author(committer).date(committerDate));
- } else {
- throw new IllegalStateException("Unable to blame file " + filename + ". No blame info at line " + lineNumber + ". Is file commited?");
- }
- insideCommitSection = false;
- insideMergedSection = false;
- author = null;
- committer = null;
- committerRevision = null;
- authorRevision = null;
- }
- }
-
- @CheckForNull
- protected Date parseDateTime(String dateTimeStr) {
- try {
- return dateFormat.parse(dateTimeStr);
- } catch (ParseException e) {
- LOG.error("skip ParseException: " + e.getMessage() + " during parsing date " + dateTimeStr, e);
- return null;
- }
- }
-
- public List<BlameLine> getLines() {
- return lines;
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnConfiguration.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnConfiguration.java
deleted file mode 100644
index 8c7db3efb6d..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnConfiguration.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.PropertyType;
-import org.sonar.api.batch.InstantiationStrategy;
-import org.sonar.api.config.PropertyDefinition;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Qualifiers;
-
-import javax.annotation.CheckForNull;
-
-import java.util.List;
-
-@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class SvnConfiguration implements BatchComponent {
-
- private static final String CATEGORY_SVN = "SVN";
- public static final String USER_PROP_KEY = "sonar.svn.username";
- public static final String PASSWORD_PROP_KEY = "sonar.svn.password.secured";
- public static final String CONFIG_DIR_PROP_KEY = "sonar.svn.config_dir";
- public static final String TRUST_SERVER_PROP_KEY = "sonar.svn.trust_server_cert";
- public static final String USE_MERGE_HISTORY_KEY = "sonar.svn.use_merge_history";
- private final Settings settings;
-
- public SvnConfiguration(Settings settings) {
- this.settings = settings;
- }
-
- public static List<PropertyDefinition> getProperties() {
- return ImmutableList.of(
- PropertyDefinition.builder(USER_PROP_KEY)
- .name("Username")
- .description("Username to be used for SVN authentication")
- .type(PropertyType.STRING)
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_SCM)
- .subCategory(CATEGORY_SVN)
- .index(0)
- .build(),
- PropertyDefinition.builder(PASSWORD_PROP_KEY)
- .name("Password")
- .description("Password to be used for SVN authentication")
- .type(PropertyType.PASSWORD)
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_SCM)
- .subCategory(CATEGORY_SVN)
- .index(1)
- .build(),
- PropertyDefinition.builder(CONFIG_DIR_PROP_KEY)
- .name("Configuration directory")
- .description("Folder containing configuration files (see --config-dir)")
- .type(PropertyType.STRING)
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_SCM)
- .subCategory(CATEGORY_SVN)
- .index(2)
- .build(),
- PropertyDefinition.builder(TRUST_SERVER_PROP_KEY)
- .name("Trust server certificate")
- .description("Accept unknown SSL certificates (like self-signed)")
- .type(PropertyType.BOOLEAN)
- .defaultValue("false")
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_SCM)
- .subCategory(CATEGORY_SVN)
- .index(3)
- .build(),
- PropertyDefinition
- .builder(USE_MERGE_HISTORY_KEY)
- .name("Use merge history for blame")
- .description(
- "Use merge history (--use-merge-history) to get real author of a modification instead of commiter of the merge. May not be supported by your SVN server/client.")
- .type(PropertyType.BOOLEAN)
- .defaultValue("false")
- .onQualifiers(Qualifiers.PROJECT)
- .category(CoreProperties.CATEGORY_SCM)
- .subCategory(CATEGORY_SVN)
- .index(4)
- .build());
- }
-
- @CheckForNull
- public String username() {
- return settings.getString(USER_PROP_KEY);
- }
-
- @CheckForNull
- public String password() {
- return settings.getString(PASSWORD_PROP_KEY);
- }
-
- @CheckForNull
- public String configDir() {
- return settings.getString(CONFIG_DIR_PROP_KEY);
- }
-
- public boolean trustServerCert() {
- return settings.getBoolean(TRUST_SERVER_PROP_KEY);
- }
-
- public boolean useMergeHistory() {
- return settings.getBoolean(USE_MERGE_HISTORY_KEY);
- }
-
-}
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnPlugin.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnPlugin.java
deleted file mode 100644
index d001cd8fd39..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnPlugin.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import com.google.common.collect.ImmutableList;
-import org.sonar.api.SonarPlugin;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public final class SvnPlugin extends SonarPlugin {
-
- @Override
- public List getExtensions() {
- List result = new ArrayList();
- result.addAll(ImmutableList.of(
- SvnScmProvider.class,
- SvnBlameCommand.class,
- SvnConfiguration.class));
- result.addAll(SvnConfiguration.getProperties());
- return result;
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnScmProvider.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnScmProvider.java
deleted file mode 100644
index 6e7fb3ac8a4..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/SvnScmProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import org.sonar.api.batch.scm.BlameCommand;
-import org.sonar.api.batch.scm.ScmProvider;
-
-import java.io.File;
-
-public class SvnScmProvider extends ScmProvider {
-
- private final SvnBlameCommand blameCommand;
-
- public SvnScmProvider(SvnBlameCommand blameCommand) {
- this.blameCommand = blameCommand;
- }
-
- @Override
- public String key() {
- return "svn";
- }
-
- @Override
- public boolean supports(File baseDir) {
- return new File(baseDir, ".svn").exists();
- }
-
- @Override
- public BlameCommand blameCommand() {
- return blameCommand;
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/package-info.java b/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/package-info.java
deleted file mode 100644
index e68270ddbe0..00000000000
--- a/plugins/sonar-svn-plugin/src/main/java/org/sonar/plugins/scm/svn/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.
- */
-
-@ParametersAreNonnullByDefault
-package org.sonar.plugins.scm.svn;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnBlameCommandTest.java b/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnBlameCommandTest.java
deleted file mode 100644
index 6b0ce9aa09e..00000000000
--- a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnBlameCommandTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.scm.BlameCommand.BlameInput;
-import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
-import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.config.PropertyDefinitions;
-import org.sonar.api.config.Settings;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.command.Command;
-import org.sonar.api.utils.command.CommandExecutor;
-import org.sonar.api.utils.command.StreamConsumer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class SvnBlameCommandTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private DefaultFileSystem fs;
- private File baseDir;
- private BlameInput input;
-
- @Before
- public void prepare() throws IOException {
- baseDir = temp.newFolder();
- fs = new DefaultFileSystem();
- fs.setBaseDir(baseDir);
- input = mock(BlameInput.class);
- when(input.fileSystem()).thenReturn(fs);
- }
-
- @Test
- public void testParsingOfOutput() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath());
- fs.add(inputFile);
-
- BlameOutput result = mock(BlameOutput.class);
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
-
- when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() {
-
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- StreamConsumer outConsumer = (StreamConsumer) invocation.getArguments()[1];
- List<String> lines = IOUtils.readLines(getClass().getResourceAsStream("/blame.xml"), "UTF-8");
- for (String line : lines) {
- outConsumer.consumeLine(line);
- }
- return 0;
- }
- });
-
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
-
- new SvnBlameCommand(commandExecutor, mock(SvnConfiguration.class)).blame(input, result);
- verify(result).blameResult(inputFile,
- Arrays.asList(
- new BlameLine().date(DateUtils.parseDateTime("2009-04-18T10:29:59+0000")).revision("9491").author("simon.brandhof"),
- new BlameLine().date(DateUtils.parseDateTime("2009-04-18T10:29:59+0000")).revision("9491").author("simon.brandhof"),
- new BlameLine().date(DateUtils.parseDateTime("2009-08-31T22:32:17+0000")).revision("10558").author("david")));
- }
-
- @Test
- public void testParsingOfOutputWithAnonymousCommit() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath());
- fs.add(inputFile);
-
- BlameOutput result = mock(BlameOutput.class);
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
-
- when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() {
-
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- StreamConsumer outConsumer = (StreamConsumer) invocation.getArguments()[1];
- List<String> lines = IOUtils.readLines(getClass().getResourceAsStream("/blame-with-anonymous-commit.xml"), "UTF-8");
- for (String line : lines) {
- outConsumer.consumeLine(line);
- }
- return 0;
- }
- });
-
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
-
- new SvnBlameCommand(commandExecutor, mock(SvnConfiguration.class)).blame(input, result);
- verify(result).blameResult(inputFile,
- Arrays.asList(
- new BlameLine().date(DateUtils.parseDateTime("2009-04-18T10:29:59+0000")).revision("9491").author("simon.brandhof"),
- new BlameLine().date(DateUtils.parseDateTime("2009-04-01T10:29:59+0000")).revision("1"),
- new BlameLine().date(DateUtils.parseDateTime("2009-08-31T22:32:17+0000")).revision("10558").author("david")));
- }
-
- @Test
- public void testParsingOfOutputWithMergeHistory() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath());
- fs.add(inputFile);
-
- BlameOutput result = mock(BlameOutput.class);
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
-
- when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() {
-
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- StreamConsumer outConsumer = (StreamConsumer) invocation.getArguments()[1];
- List<String> lines = IOUtils.readLines(getClass().getResourceAsStream("/blame-with-merge-history.xml"), "UTF-8");
- for (String line : lines) {
- outConsumer.consumeLine(line);
- }
- return 0;
- }
- });
-
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
-
- new SvnBlameCommand(commandExecutor, mock(SvnConfiguration.class)).blame(input, result);
- verify(result).blameResult(inputFile,
- Arrays.asList(
- new BlameLine().date(DateUtils.parseDateTime("2012-07-19T11:44:57+0200")).revision("9490").author("dgageot"),
- new BlameLine().date(DateUtils.parseDateTime("2009-04-18T10:29:59+0000")).revision("9491").author("simon.brandhof"),
- new BlameLine().date(DateUtils.parseDateTime("2009-08-31T22:32:17+0000")).revision("10558").author("david")));
- }
-
- @Test
- public void shouldFailIfFileContainsLocalModification() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath());
- fs.add(inputFile);
-
- BlameOutput result = mock(BlameOutput.class);
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
-
- when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() {
-
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- StreamConsumer outConsumer = (StreamConsumer) invocation.getArguments()[1];
- List<String> lines = IOUtils.readLines(getClass().getResourceAsStream("/blame-with-uncomitted-changes.xml"), "UTF-8");
- for (String line : lines) {
- outConsumer.consumeLine(line);
- }
- return 0;
- }
- });
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("Unable to blame file src/foo.xoo. No blame info at line 2. Is file commited?");
-
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
- new SvnBlameCommand(commandExecutor, mock(SvnConfiguration.class)).blame(input, result);
- }
-
- @Test
- public void testExecutionError() throws IOException {
- File source = new File(baseDir, "src/foo.xoo");
- FileUtils.write(source, "sample content");
- DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath());
- fs.add(inputFile);
-
- BlameOutput result = mock(BlameOutput.class);
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
-
- when(commandExecutor.execute(any(Command.class), any(StreamConsumer.class), any(StreamConsumer.class), anyLong())).thenAnswer(new Answer<Integer>() {
-
- @Override
- public Integer answer(InvocationOnMock invocation) throws Throwable {
- StreamConsumer errConsumer = (StreamConsumer) invocation.getArguments()[2];
- errConsumer.consumeLine("My error");
- return 1;
- }
- });
-
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("The svn blame command [svn blame --xml --non-interactive -x -w src/foo.xoo] failed: My error");
-
- when(input.filesToBlame()).thenReturn(Arrays.<InputFile>asList(inputFile));
- new SvnBlameCommand(commandExecutor, mock(SvnConfiguration.class)).blame(input, result);
- }
-
- @Test
- public void testAllParams() {
- CommandExecutor commandExecutor = mock(CommandExecutor.class);
- Settings settings = new Settings(new PropertyDefinitions(SvnConfiguration.getProperties()));
- SvnBlameCommand svnBlameCommand = new SvnBlameCommand(commandExecutor, new SvnConfiguration(settings));
-
- Command commandLine = svnBlameCommand.createCommandLine(baseDir, "src/main/java/Foo.java");
- assertThat(commandLine.toCommandLine()).isEqualTo("svn blame --xml --non-interactive -x -w src/main/java/Foo.java");
- assertThat(commandLine.toString()).isEqualTo("svn blame --xml --non-interactive -x -w src/main/java/Foo.java");
-
- settings.setProperty(SvnConfiguration.USER_PROP_KEY, "myUser");
- settings.setProperty(SvnConfiguration.PASSWORD_PROP_KEY, "myPass");
- commandLine = svnBlameCommand.createCommandLine(baseDir, "src/main/java/Foo.java");
- assertThat(commandLine.toCommandLine()).isEqualTo("svn blame --xml --non-interactive -x -w --username myUser --password myPass src/main/java/Foo.java");
- assertThat(commandLine.toString()).isEqualTo("svn blame --xml --non-interactive -x -w --username ******** --password ******** src/main/java/Foo.java");
-
- settings.setProperty(SvnConfiguration.CONFIG_DIR_PROP_KEY, "/home/julien/.svn");
- settings.setProperty(SvnConfiguration.TRUST_SERVER_PROP_KEY, "true");
- settings.setProperty(SvnConfiguration.USE_MERGE_HISTORY_KEY, "true");
- commandLine = svnBlameCommand.createCommandLine(baseDir, "src/main/java/Foo.java");
- assertThat(commandLine.toCommandLine())
- .isEqualTo(
- "svn blame --xml --use-merge-history --non-interactive -x -w --config-dir /home/julien/.svn --username myUser --password myPass --trust-server-cert src/main/java/Foo.java");
- assertThat(commandLine.toString())
- .isEqualTo(
- "svn blame --xml --use-merge-history --non-interactive -x -w --config-dir /home/julien/.svn --username ******** --password ******** --trust-server-cert src/main/java/Foo.java");
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnPluginTest.java b/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnPluginTest.java
deleted file mode 100644
index cc4af84faf8..00000000000
--- a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnPluginTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class SvnPluginTest {
-
- @Test
- public void getExtensions() {
- assertThat(new SvnPlugin().getExtensions()).hasSize(8);
- }
-}
diff --git a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnScmProviderTest.java b/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnScmProviderTest.java
deleted file mode 100644
index 89da5df4b18..00000000000
--- a/plugins/sonar-svn-plugin/src/test/java/org/sonar/plugins/scm/svn/SvnScmProviderTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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.plugins.scm.svn;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-
-import java.io.File;
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class SvnScmProviderTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void sanityCheck() {
- SvnBlameCommand blameCommand = new SvnBlameCommand(mock(SvnConfiguration.class));
- SvnScmProvider svnScmProvider = new SvnScmProvider(blameCommand);
- assertThat(svnScmProvider.key()).isEqualTo("svn");
- assertThat(svnScmProvider.blameCommand()).isEqualTo(blameCommand);
- }
-
- @Test
- public void testAutodetection() throws IOException {
- File baseDirEmpty = temp.newFolder();
- assertThat(new SvnScmProvider(null).supports(baseDirEmpty)).isFalse();
-
- File svnBaseDir = temp.newFolder();
- new File(svnBaseDir, ".svn").mkdir();
- assertThat(new SvnScmProvider(null).supports(svnBaseDir)).isTrue();
- }
-
-}
diff --git a/plugins/sonar-svn-plugin/src/test/resources/blame-with-anonymous-commit.xml b/plugins/sonar-svn-plugin/src/test/resources/blame-with-anonymous-commit.xml
deleted file mode 100644
index 2a08a62dc32..00000000000
--- a/plugins/sonar-svn-plugin/src/test/resources/blame-with-anonymous-commit.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blame>
-<target
- path="pom.xml">
-<entry
- line-number="1">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-</entry>
-<entry
- line-number="2">
-<commit
- revision="1">
-<date>2009-04-01T10:29:59.077093Z</date>
-</commit>
-</entry>
-<entry
- line-number="3">
-<commit
- revision="10558">
-<author>david</author>
-<date>2009-08-31T22:32:17.361675Z</date>
-</commit>
-</entry>
-</target>
-</blame>
diff --git a/plugins/sonar-svn-plugin/src/test/resources/blame-with-merge-history.xml b/plugins/sonar-svn-plugin/src/test/resources/blame-with-merge-history.xml
deleted file mode 100644
index efe87073a7a..00000000000
--- a/plugins/sonar-svn-plugin/src/test/resources/blame-with-merge-history.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blame>
-<target
- path="pom.xml">
-<entry
- line-number="1">
-<commit
- revision="9491">
-<author>automatic-merge</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-<merged
- path="/dummy-svn/pom.xml">
-<commit
- revision="9490">
-<author>dgageot</author>
-<date>2012-07-19T09:44:57.393222Z</date>
-</commit>
-</merged>
-</entry>
-<entry
- line-number="2">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-<merged
- path="/dummy-svn/pom.xml">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-</merged>
-</entry>
-<entry
- line-number="3">
-<commit
- revision="10558">
-<author>david</author>
-<date>2009-08-31T22:32:17.361675Z</date>
-</commit>
-<merged
- path="/dummy-svn/pom.xml">
-<commit
- revision="10558">
-<author>david</author>
-<date>2009-08-31T22:32:17.361675Z</date>
-</commit>
-</merged>
-</entry>
-</target>
-</blame>
diff --git a/plugins/sonar-svn-plugin/src/test/resources/blame-with-uncomitted-changes.xml b/plugins/sonar-svn-plugin/src/test/resources/blame-with-uncomitted-changes.xml
deleted file mode 100644
index 76fcdc4b98e..00000000000
--- a/plugins/sonar-svn-plugin/src/test/resources/blame-with-uncomitted-changes.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blame>
-<target
- path="pom.xml">
-<entry
- line-number="1">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-</entry>
-<entry
- line-number="2">
-</entry>
-<entry
- line-number="3">
-<commit
- revision="10558">
-<author>david</author>
-<date>2009-08-31T22:32:17.361675Z</date>
-</commit>
-</entry>
-</target>
-</blame>
diff --git a/plugins/sonar-svn-plugin/src/test/resources/blame.xml b/plugins/sonar-svn-plugin/src/test/resources/blame.xml
deleted file mode 100644
index 479dee9c692..00000000000
--- a/plugins/sonar-svn-plugin/src/test/resources/blame.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blame>
-<target
- path="pom.xml">
-<entry
- line-number="1">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-</entry>
-<entry
- line-number="2">
-<commit
- revision="9491">
-<author>simon.brandhof</author>
-<date>2009-04-18T10:29:59.077093Z</date>
-</commit>
-</entry>
-<entry
- line-number="3">
-<commit
- revision="10558">
-<author>david</author>
-<date>2009-08-31T22:32:17.361675Z</date>
-</commit>
-</entry>
-</target>
-</blame>
diff --git a/pom.xml b/pom.xml
index 3041c24e976..67787434c99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,8 +33,6 @@
<module>plugins/sonar-cpd-plugin</module>
<module>plugins/sonar-l10n-en-plugin</module>
<module>plugins/sonar-email-notifications-plugin</module>
- <module>plugins/sonar-git-plugin</module>
- <module>plugins/sonar-svn-plugin</module>
<module>plugins/sonar-xoo-plugin</module>
</modules>
@@ -70,6 +68,8 @@
<properties>
<sonarUpdateCenter.version>1.11</sonarUpdateCenter.version>
<sonarJava.version>2.8</sonarJava.version>
+ <sonarGit.version>1.0-SNAPSHOT</sonarGit.version>
+ <sonarSvn.version>1.0-SNAPSHOT</sonarSvn.version>
<h2.version>1.3.176</h2.version>
<jetty.version>8.1.12.v20130726</jetty.version>
<logback.version>1.0.13</logback.version>
@@ -592,15 +592,15 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
+ <groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>sonar-scm-git-plugin</artifactId>
- <version>${project.version}</version>
+ <version>${sonarGit.version}</version>
<type>sonar-plugin</type>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
+ <groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>sonar-scm-svn-plugin</artifactId>
- <version>${project.version}</version>
+ <version>${sonarSvn.version}</version>
<type>sonar-plugin</type>
</dependency>
<dependency>
diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml
index 98dec35edfe..dcd6c6db5c8 100644
--- a/sonar-application/pom.xml
+++ b/sonar-application/pom.xml
@@ -130,13 +130,13 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
+ <groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>sonar-scm-git-plugin</artifactId>
<type>sonar-plugin</type>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.sonar.plugins</groupId>
+ <groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>sonar-scm-svn-plugin</artifactId>
<type>sonar-plugin</type>
<scope>provided</scope>