All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jarch.svn.DiffSvn Maven / Gradle / Ivy

The newest version!
package br.com.jarch.svn;

import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.wc.SVNDiffClient;
import org.tmatesoft.svn.core.wc.SVNRevision;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.stream.Collectors;

class DiffSvn extends BaseSvn {

    private static final long serialVersionUID = -7046346153335029307L;

    public DiffSvn(List log, String login, String senha) {
        super(log, login, senha);
    }

    public List diff(File arquivo) throws Exception {
        if (!arquivo.exists()) {
            throw new Exception("Pasta trabalho " + arquivo.getAbsolutePath() + " NÃO Localizado ");
        }

        logUtil.formatBegin(log, "DIFF");

        SVNDiffClient diffClient = getDiffClient();

        File arquivoDiff = File.createTempFile("gpd-fx-diff", ".txt");
        arquivoDiff.deleteOnExit();

        OutputStream os = new FileOutputStream(arquivoDiff);

        diffClient.doDiff(arquivo, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNRevision.WORKING, SVNDepth.INFINITY, true, os, null);

        logUtil.formatMiddle(log, String.join("\n", FileSvnUtils.content(arquivoDiff)));

        logUtil.formatBegin(log, "FIM");

        return FileSvnUtils.content(arquivoDiff);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy