Search in sources :

Example 1 with PlotCommitList

use of org.eclipse.jgit.revplot.PlotCommitList 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 PlotCommitList

use of org.eclipse.jgit.revplot.PlotCommitList 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.maven.atlas.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)

Aggregations

PlotCommitList (org.eclipse.jgit.revplot.PlotCommitList)2 PlotLane (org.eclipse.jgit.revplot.PlotLane)2 PlotWalk (org.eclipse.jgit.revplot.PlotWalk)2 IOException (java.io.IOException)1 JoinString (org.commonjava.maven.atlas.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