Search in sources :

Example 1 with PlotLane

use of org.eclipse.jgit.revplot.PlotLane in project gitblit by gitblit.

the class JGitUtilsTest method testPlots.

@Test
public void testPlots() throws Exception {
    Repository repository = GitBlitSuite.getTicgitRepository();
    PlotWalk pw = new PlotWalk(repository);
    PlotCommitList<PlotLane> commits = new PlotCommitList<PlotLane>();
    commits.source(pw);
    commits.fillTo(25);
    for (PlotCommit<PlotLane> commit : commits) {
        System.out.println(commit);
    }
    repository.close();
}
Also used : Repository(org.eclipse.jgit.lib.Repository) PlotLane(org.eclipse.jgit.revplot.PlotLane) PlotCommitList(org.eclipse.jgit.revplot.PlotCommitList) PlotWalk(org.eclipse.jgit.revplot.PlotWalk) Test(org.junit.Test)

Example 2 with PlotLane

use of org.eclipse.jgit.revplot.PlotLane in project indy by Commonjava.

the class GitManager method getHeadCommit.

public ChangeSummary getHeadCommit(final File f) throws GitSubsystemException {
    return lockAnd(me -> {
        try {
            final ObjectId oid = repo.resolve("HEAD");
            final PlotWalk pw = new PlotWalk(repo);
            final RevCommit rc = pw.parseCommit(oid);
            pw.markStart(rc);
            final String filepath = relativize(f);
            pw.setTreeFilter(AndTreeFilter.create(PathFilter.create(filepath), TreeFilter.ANY_DIFF));
            final PlotCommitList<PlotLane> cl = new PlotCommitList<>();
            cl.source(pw);
            cl.fillTo(1);
            final PlotCommit<PlotLane> commit = cl.get(0);
            return toChangeSummary(commit);
        } catch (RevisionSyntaxException | IOException e) {
            throw new GitSubsystemException("Failed to resolve HEAD commit for: %s. Reason: %s", e, f, e.getMessage());
        }
    });
}
Also used : PlotLane(org.eclipse.jgit.revplot.PlotLane) ObjectId(org.eclipse.jgit.lib.ObjectId) RevisionSyntaxException(org.eclipse.jgit.errors.RevisionSyntaxException) JoinString(org.commonjava.atlas.maven.ident.util.JoinString) PlotCommitList(org.eclipse.jgit.revplot.PlotCommitList) IOException(java.io.IOException) PlotWalk(org.eclipse.jgit.revplot.PlotWalk) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Example 3 with PlotLane

use of org.eclipse.jgit.revplot.PlotLane in project ontrack by nemerosa.

the class GitRepositoryClientImpl method graph.

@Override
public GitLog graph(String from, String to) {
    try {
        GitRange range = range(from, to, false);
        PlotWalk walk = new PlotWalk(git.getRepository());
        // Log
        walk.markStart(walk.lookupCommit(range.getFrom().getId()));
        walk.markUninteresting(walk.lookupCommit(range.getTo().getId()));
        PlotCommitList<PlotLane> commitList = new PlotCommitList<>();
        commitList.source(walk);
        commitList.fillTo(Integer.MAX_VALUE);
        // Rendering
        GitPlotRenderer renderer = new GitPlotRenderer(commitList);
        GPlot plot = renderer.getPlot();
        // Gets the commits
        List<GitCommit> commits = Lists.transform(renderer.getCommits(), this::toCommit);
        // OK
        return new GitLog(plot, commits);
    } catch (IOException e) {
        throw new GitRepositoryIOException(repository.getRemote(), e);
    }
}
Also used : GitPlotRenderer(net.nemerosa.ontrack.git.model.plot.GitPlotRenderer) PlotLane(org.eclipse.jgit.revplot.PlotLane) GPlot(net.nemerosa.ontrack.git.model.plot.GPlot) PlotCommitList(org.eclipse.jgit.revplot.PlotCommitList) IOException(java.io.IOException) PlotWalk(org.eclipse.jgit.revplot.PlotWalk)

Aggregations

PlotCommitList (org.eclipse.jgit.revplot.PlotCommitList)3 PlotLane (org.eclipse.jgit.revplot.PlotLane)3 PlotWalk (org.eclipse.jgit.revplot.PlotWalk)3 IOException (java.io.IOException)2 GPlot (net.nemerosa.ontrack.git.model.plot.GPlot)1 GitPlotRenderer (net.nemerosa.ontrack.git.model.plot.GitPlotRenderer)1 JoinString (org.commonjava.atlas.maven.ident.util.JoinString)1 RevisionSyntaxException (org.eclipse.jgit.errors.RevisionSyntaxException)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 Repository (org.eclipse.jgit.lib.Repository)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 Test (org.junit.Test)1