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

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

Introduction

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

Prototype

@Override
public Note call() throws GitAPIException 

Source Link

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   w  ww  .j a  v  a 2s.  c o 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);
    }
}