Example usage for org.eclipse.jgit.api ListNotesCommand call

List of usage examples for org.eclipse.jgit.api ListNotesCommand call

Introduction

In this page you can find the example usage for org.eclipse.jgit.api ListNotesCommand call.

Prototype

@Override
public List<Note> call() throws GitAPIException 

Source Link

Usage

From source file:com.google.appraise.eclipse.core.client.git.AppraiseGitReviewClient.java

License:Open Source License

/**
 * Retrieves all the reviews in the current project's repository by commit hash.
 *//*from w  w  w . java 2  s  .  co  m*/
public Map<String, Review> listReviews() throws GitClientException {
    // Get the most up-to-date list of reviews.
    syncCommentsAndReviews();

    Map<String, Review> reviews = new LinkedHashMap<>();

    Git git = new Git(repo);
    try {
        ListNotesCommand cmd = git.notesList();
        cmd.setNotesRef(REVIEWS_REF);
        List<Note> notes = cmd.call();
        for (Note note : notes) {
            String rawNoteDataStr = noteToString(repo, note);
            Review latest = extractLatestReviewFromNotes(rawNoteDataStr);
            if (latest != null) {
                reviews.put(note.getName(), latest);
            }
        }
    } catch (Exception e) {
        throw new GitClientException(e);
    } finally {
        git.close();
    }
    return reviews;
}