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

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

Introduction

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

Prototype

public ShowNoteCommand setObjectId(RevObject id) 

Source Link

Document

Sets the object id of object you want a note on

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.
 *//*from   ww  w . j a  va2 s  .co  m*/
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);
    }
}