diff options
3 files changed, 9 insertions, 2 deletions
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 index 3e3d6642e2b..4d02b1cfeda 100644 --- 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 @@ -23,6 +23,8 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.BatchComponent; import org.sonar.api.batch.InstantiationStrategy; import org.sonar.api.batch.fs.FileSystem; @@ -39,6 +41,8 @@ import java.util.List; @InstantiationStrategy(InstantiationStrategy.PER_BATCH) public class JGitBlameCommand implements BlameCommand, BatchComponent { + private static final Logger LOG = LoggerFactory.getLogger(JGitBlameCommand.class); + private final PathResolver pathResolver; public JGitBlameCommand(PathResolver pathResolver) { @@ -76,6 +80,9 @@ public class JGitBlameCommand implements BlameCommand, BatchComponent { List<BlameLine> lines = new ArrayList<BlameLine>(); for (int i = 0; i < blameResult.getResultContents().size(); i++) { if (blameResult.getSourceAuthor(i) == null || blameResult.getSourceCommit(i) == null || blameResult.getSourceCommitter(i) == null) { + LOG.info("Author: " + blameResult.getSourceAuthor(i)); + LOG.info("Committer: " + blameResult.getSourceCommitter(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(blameResult.getSourceAuthor(i).getWhen(), diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java index 93269c7a32a..f62e3d00683 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameResult.java @@ -52,7 +52,7 @@ class DefaultBlameResult implements BlameResult { Preconditions.checkNotNull(file); Preconditions.checkNotNull(lines); Preconditions.checkArgument(lines.size() == file.lines(), - "Expected one blame result per line but provider returned " + lines.size() + " blame lines while file has " + file.lines() + " lines"); + "Expected one blame result per line but provider returned " + lines.size() + " blame lines while file " + file.relativePath() + " has " + file.lines() + " lines"); PropertiesBuilder<Integer, String> authors = propertiesBuilder(CoreMetrics.SCM_AUTHORS_BY_LINE); PropertiesBuilder<Integer, String> dates = propertiesBuilder(CoreMetrics.SCM_LAST_COMMIT_DATETIMES_BY_LINE); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java b/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java index c64f7ebc6ee..90d7dc7e1f6 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scm/DefaultBlameResultTest.java @@ -38,7 +38,7 @@ public class DefaultBlameResultTest { InputFile file = new DefaultInputFile("foo", "src/main/java/Foo.java").setLines(10); thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("Expected one blame result per line but provider returned 1 blame lines while file has 10 lines"); + thrown.expectMessage("Expected one blame result per line but provider returned 1 blame lines while file src/main/java/Foo.java has 10 lines"); new DefaultBlameResult(null).add(file, Arrays.asList(new BlameLine(null, "1", "guy"))); } |