Search in sources :

Example 1 with SVNDiffOptions

use of org.tmatesoft.svn.core.wc.SVNDiffOptions in project sonarqube by SonarSource.

the class SvnBlameCommand method blame.

@VisibleForTesting
void blame(SVNClientManager clientManager, InputFile inputFile, BlameOutput output) {
    String filename = inputFile.relativePath();
    LOG.debug("Process file {}", filename);
    AnnotationHandler handler = new AnnotationHandler();
    try {
        if (!checkStatus(clientManager, inputFile)) {
            return;
        }
        SVNLogClient logClient = clientManager.getLogClient();
        logClient.setDiffOptions(new SVNDiffOptions(true, true, true));
        logClient.doAnnotate(inputFile.file(), SVNRevision.UNDEFINED, SVNRevision.create(1), SVNRevision.BASE, true, true, handler, null);
    } catch (SVNAuthenticationException e) {
        if (configuration.isEmpty()) {
            LOG.warn("Authentication to SVN server is required but no authentication data was passed to the scanner");
        }
        throw new IllegalStateException("Authentication error when executing blame for file " + filename, e);
    } catch (SVNException e) {
        throw new IllegalStateException("Error when executing blame for file " + filename, e);
    }
    List<BlameLine> lines = handler.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);
}
Also used : BlameLine(org.sonar.api.batch.scm.BlameLine) SVNAuthenticationException(org.tmatesoft.svn.core.SVNAuthenticationException) SVNDiffOptions(org.tmatesoft.svn.core.wc.SVNDiffOptions) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BlameLine (org.sonar.api.batch.scm.BlameLine)1 SVNAuthenticationException (org.tmatesoft.svn.core.SVNAuthenticationException)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNDiffOptions (org.tmatesoft.svn.core.wc.SVNDiffOptions)1 SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)1