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

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

Introduction

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

Prototype

public ListNotesCommand setNotesRef(String notesRef) 

Source Link

Document

Set the Ref to read notes from

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.
 */// www .j  a  v a 2s  .c  o  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;
}