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

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

Introduction

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

Prototype

public ShowNoteCommand 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

/**
 * Reads a single note out as a string from the given commit hash.
 * Returns null if the note isn't found.
 *//* w ww  . ja  v  a 2 s  . com*/
private String readOneNote(Git git, String notesRef, String hash) throws GitClientException {
    try (RevWalk walker = new RevWalk(git.getRepository())) {
        ShowNoteCommand cmd = git.notesShow();
        cmd.setNotesRef(notesRef);
        ObjectId ref = git.getRepository().resolve(hash);
        RevCommit commit = walker.parseCommit(ref);
        cmd.setObjectId(commit);
        Note note = cmd.call();
        if (note == null) {
            return null;
        }
        return noteToString(repo, note);
    } catch (Exception e) {
        throw new GitClientException(e);
    }
}