Example usage for org.eclipse.jgit.revplot PlotCommitList source

List of usage examples for org.eclipse.jgit.revplot PlotCommitList source

Introduction

In this page you can find the example usage for org.eclipse.jgit.revplot PlotCommitList source.

Prototype

@Override
public void source(RevWalk w) 

Source Link

Usage

From source file:com.gitblit.tests.JGitUtilsTest.java

License:Apache License

@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);/*www . j  a va 2s.c o m*/
    for (PlotCommit<PlotLane> commit : commits) {
        System.out.println(commit);
    }
    repository.close();
}

From source file:com.madgag.agit.CommitViewerActivity.java

License:Open Source License

private PlotWalk generatePlotWalk() throws IOException {
    long start = currentTimeMillis();
    PlotWalk revWalk = new PlotWalk(repo());

    for (ObjectId startId : logStartProvider.get()) {
        revWalk.markStart(revWalk.parseCommit(startId));
    }/*  w  ww.  ja v  a  2 s.  co m*/

    PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<PlotLane>();
    plotCommitList.source(revWalk);
    plotCommitList.fillTo(Integer.MAX_VALUE);
    long duration = currentTimeMillis() - start;
    Log.d(TAG, "generatePlotWalk duration" + duration);
    return revWalk;
}

From source file:de.fau.osr.core.vcs.impl.GitVcsClient.java

License:Open Source License

public Iterator<String> getCommitListForFileodification(String path) {
    String filename = path.replaceAll(Matcher.quoteReplacement("\\"), "/");
    PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<PlotLane>();
    PlotWalk revWalk = new PlotWalk(repo);
    ArrayList<String> commitIDList = new ArrayList<String>();
    try {/*from  www .  j  a va  2s  .  c o m*/
        ObjectId rootId = repo.resolve("HEAD");
        if (rootId != null) {
            RevCommit root = revWalk.parseCommit(rootId);
            revWalk.markStart(root);
            revWalk.setTreeFilter(
                    // VERY IMPORTANT: This works only with unix-style file paths. NO "\" allowed.
                    AndTreeFilter.create(PathFilter.create(filename), TreeFilter.ANY_DIFF));
            plotCommitList.source(revWalk);
            plotCommitList.fillTo(Integer.MAX_VALUE);

            Iterator<PlotCommit<PlotLane>> commitListIterator = plotCommitList.iterator();
            while (commitListIterator.hasNext()) {
                commitIDList.add(commitListIterator.next().getName());
            }
            return commitIDList.iterator();
        }

    } catch (AmbiguousObjectException ex) {

    } catch (IOException ex) {

    }
    return commitIDList.iterator();
}

From source file:edu.nju.cs.inform.jgit.unfinished.ListChildrenOfCommit.java

License:Apache License

public static void main(String[] args) throws IOException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        try (PlotWalk revWalk = new PlotWalk(repository)) {
            ObjectId rootId = repository.resolve("refs/heads/master");
            RevCommit root = revWalk.parseCommit(rootId);
            revWalk.markStart(root);//www.jav  a 2  s. com
            PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<>();
            plotCommitList.source(revWalk);
            plotCommitList.fillTo(Integer.MAX_VALUE);

            System.out.println("Printing children of commit " + root);
            for (RevCommit com : revWalk) {
                System.out.println("Child: " + com);
            }

            System.out.println("Printing with next()");
            System.out.println("next: " + revWalk.next());
        }
    }
}

From source file:org.commonjava.aprox.subsys.git.GitManager.java

License:Apache License

public ChangeSummary getHeadCommit(final File f) throws GitSubsystemException {
    try {/*  ww w.  ja v a  2  s.  com*/
        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());
    }
}

From source file:org.commonjava.indy.subsys.git.GitManager.java

License:Apache License

public ChangeSummary getHeadCommit(final File f) throws GitSubsystemException {
    return lockAnd(me -> {
        try {//from  w ww  .j a v a2 s  . co  m
            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());
        }
    });
}

From source file:org.efaps.cli.rest.ImportCICall.java

License:Apache License

/**
 * Gets the file information./*ww w.j  a v  a  2  s.com*/
 *
 * @param _file the _file
 * @return the file information
 */
protected String[] getFileInformation(final File _file) {
    final String[] ret = new String[2];

    try {
        final Repository repo = new FileRepository(evalGitDir(_file));

        final ObjectId lastCommitId = repo.resolve(Constants.HEAD);

        final PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<PlotLane>();
        final PlotWalk revWalk = new PlotWalk(repo);

        final RevCommit root = revWalk.parseCommit(lastCommitId);
        revWalk.markStart(root);
        revWalk.setTreeFilter(AndTreeFilter.create(
                PathFilter.create(_file.getPath().replaceFirst(repo.getWorkTree().getPath() + "/", "")),
                TreeFilter.ANY_DIFF));
        plotCommitList.source(revWalk);
        plotCommitList.fillTo(2);
        final PlotCommit<PlotLane> commit = plotCommitList.get(0);
        if (commit != null) {
            final PersonIdent authorIdent = commit.getAuthorIdent();
            final Date authorDate = authorIdent.getWhen();
            final TimeZone authorTimeZone = authorIdent.getTimeZone();
            final DateTime dateTime = new DateTime(authorDate.getTime(),
                    DateTimeZone.forTimeZone(authorTimeZone));
            ret[1] = dateTime.toString();
            ret[0] = commit.getId().getName();
        } else {
            ret[1] = new DateTime().toString();
            ret[0] = "UNKNOWN";
        }
    } catch (final RevisionSyntaxException | IOException e) {
        e.printStackTrace();
    }
    return ret;
}

From source file:org.efaps.eclipse.rest.RestClient.java

License:Apache License

protected String[] getFileInformation(final File _file) {
    final String[] ret = new String[2];

    try {//from   w  w w . ja v  a 2 s.c  o  m
        final Repository repo = new FileRepository(evalGitDir(_file));

        final ObjectId lastCommitId = repo.resolve(Constants.HEAD);

        final PlotCommitList<PlotLane> plotCommitList = new PlotCommitList<PlotLane>();
        final PlotWalk revWalk = new PlotWalk(repo);

        final RevCommit root = revWalk.parseCommit(lastCommitId);
        revWalk.markStart(root);
        revWalk.setTreeFilter(AndTreeFilter.create(
                PathFilter.create(_file.getPath().replaceFirst(repo.getWorkTree().getPath() + "/", "")),
                TreeFilter.ANY_DIFF));
        plotCommitList.source(revWalk);
        plotCommitList.fillTo(2);
        final PlotCommit<PlotLane> commit = plotCommitList.get(0);
        if (commit != null) {
            final PersonIdent authorIdent = commit.getAuthorIdent();
            final Date authorDate = authorIdent.getWhen();
            final TimeZone authorTimeZone = authorIdent.getTimeZone();
            final DateTime dateTime = new DateTime(authorDate.getTime(),
                    DateTimeZone.forTimeZone(authorTimeZone));
            ret[1] = dateTime.toString();
            ret[0] = commit.getId().getName();
        } else {
            ret[1] = new DateTime().toString();
            ret[0] = "UNKNOWN";
        }
    } catch (RevisionSyntaxException | IOException e) {
        e.printStackTrace();
    }
    return ret;
}