Example usage for org.eclipse.jgit.revplot PlotCommit getAuthorIdent

List of usage examples for org.eclipse.jgit.revplot PlotCommit getAuthorIdent

Introduction

In this page you can find the example usage for org.eclipse.jgit.revplot PlotCommit getAuthorIdent.

Prototype

public final PersonIdent getAuthorIdent() 

Source Link

Document

Parse the author identity from the raw buffer.

Usage

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

License:Open Source License

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    try {// ww w  .  j  a v  a2  s .  co  m
        Repository repository = new FileRepository(gitDirFrom(getArguments()));
        ObjectId commitId = revisionIdFrom(repository, getArguments(), REVISION);
        Log.d(TAG, "onCreateView with " + commitId);

        View v = inflater.inflate(R.layout.commit_detail_view, container, false);

        CommitNavigationView commitNavigationView = (CommitNavigationView) v
                .findViewById(R.id.commit_navigation);

        commitNavigationView.setCommitSelectedListener(commitSelectedListener);
        PlotCommit<PlotLane> commit = commitSelectedListener.plotCommitFor(commitId);

        commitNavigationView.setCommit(commit);

        ((ObjectIdView) v.findViewById(R.id.commit_id)).setObjectId(commit);

        ViewGroup vg = (ViewGroup) v.findViewById(R.id.commit_people_group);

        PersonIdent author = commit.getAuthorIdent(), committer = commit.getCommitterIdent();
        if (author.equals(committer)) {
            addPerson("Author & Committer", author, vg);
        } else {
            addPerson("Author", author, vg);
            addPerson("Committer", committer, vg);
        }
        TextView textView = (TextView) v.findViewById(R.id.commit_message_text);
        textView.setText(commit.getFullMessage());
        return v;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

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

License:Open Source License

private void showCommitDetailsFor(final PlotCommit<PlotLane> commit) {
    commitNavigationView = (CommitNavigationView) findViewById(R.id.commit_navigation);
    Log.d("CV", "Got commitNavigationView=" + commitNavigationView + " commitSelectedListener="
            + commitSelectedListener);//from  ww w .j  a  v a2s.c o  m
    commitNavigationView.setCommitSelectedListener(commitSelectedListener);

    ((ObjectIdView) findViewById(R.id.commit_id)).setObjectId(commit);

    ViewGroup vg = (ViewGroup) findViewById(R.id.commit_people_group);

    PersonIdent author = commit.getAuthorIdent(), committer = commit.getCommitterIdent();
    if (author.equals(committer)) {
        addPerson("Author & Committer", author, vg);
    } else {
        addPerson("Author", author, vg);
        addPerson("Committer", committer, vg);
    }
    //      ViewGroup vg = (ViewGroup) findViewById(R.id.commit_refs_group);
    //      for (int i=0; i<commit.getRefCount(); ++i) {
    //         TextView tv = new TextView(getContext());
    //         tv.setText(commit.getRef(i).getName());
    //         vg.addView(tv);
    //      }
    TextView textView = (TextView) findViewById(R.id.commit_message_text);
    textView.setText(commit.getFullMessage());
    //      
    //      int width=textView.getBackground().getIntrinsicWidth(); // textView.getBackground is null at somepoint?
    //      Log.d("CV", "M Width = "+width);
    //      textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, width/80);
}

From source file:de.br0tbox.gitfx.ui.sync.SynchronizationTask.java

License:Apache License

private void refreshCommits() throws MissingObjectException, IncorrectObjectTypeException, IOException {
    final Repository repository = projectModel.getFxProject().getGit().getRepository();
    final RevWalk revWalk = new PlotWalk(repository);
    revWalk.markStart(revWalk.parseCommit(repository.getRef("master").getObjectId()));
    final JavaFxCommitList commitList = new JavaFxCommitList();
    commitList.source(revWalk);// w w w.  j a  v  a2  s  . co m
    commitList.fillTo(512);
    PlotCommit<?>[] array = new PlotCommit[commitList.size()];
    array = commitList.toArray(array);
    final List<GitFxCommit> commits = new ArrayList<>(array.length);
    for (final PlotCommit<?> commit : array) {
        final GitFxCommit gitFxCommit = new GitFxCommit(commit.abbreviate(7).name(),
                commit.getAuthorIdent().getName(), commit.getShortMessage(), commit);
        commits.add(gitFxCommit);
    }
    revWalk.release();
    Platform.runLater(new Runnable() {

        @Override
        public void run() {
            projectModel.getCommitsProperty().clear();
            projectModel.getCommitsProperty().addAll(commits);
        }
    });
}

From source file:org.commonjava.freeki.data.FreekiStore.java

License:Open Source License

public Page getPage(final String group, final String id) throws IOException {
    final File file = getFileById(group, id);
    if (!file.exists()) {
        return null;
    }//from w w w.  jav a 2s  .c  o  m

    String content = readFileToString(file);

    PlotCommit<PlotLane> commit;
    try {
        commit = git.getHeadCommit(file);
    } catch (final Exception e) {
        throw new IOException(
                String.format("Failed to read commit information for: %s. Reason: %s", file, e.getMessage()),
                e);
    }

    final Map<String, String> metadata = getMetadata(content, true);
    content = metadata.remove(MD_CONTENT);
    final String title = metadata.get(MD_TITLE);
    final PersonIdent ai = commit.getAuthorIdent();

    return new Page(group, id, content, title, ai.getWhen().getTime(), ai.getName());
}

From source file:org.commonjava.freeki.store.GitManagerTest.java

License:Open Source License

@Test
public void getLogForValidFile() throws Exception {
    final PlotCommit<PlotLane> log = git.getHeadCommit(new File(dir, "mygroup/page-id.md"));
    assertThat(log, notNullValue());//from   w  w w . j ava 2s .co m
    final PersonIdent ident = log.getAuthorIdent();
    assertThat(ident, notNullValue());
    assertThat(ident.getName(), notNullValue());
    assertThat(ident.getEmailAddress(), notNullValue());
    assertThat(ident.getWhen(), notNullValue());

    final String message = log.getFullMessage();
    assertThat(message, notNullValue());

    System.out.printf("%s %s %s %s %s\n\n%s\n", ident.getName(), ident.getEmailAddress(), ident.getWhen(),
            ident.getTimeZone().getID(), ident.getTimeZoneOffset(), message);
}

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

License:Apache License

/**
 * Gets the file information.//from   w w  w.j a v  a2s.  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 ww.j  av  a  2s  .  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;
}