Reputation: 2491
Is there a java api for git, which allows for fetching git notes from a repository? I looked at http://server001.agilebackoffice.org/nexus/content/repositories/atlassian/com/xiplink/jira/git/jira-git-plugin/0.6/ but it looks like it doesnt seem to support git notes. Any ideas where to look out for?
Upvotes: 1
Views: 147
Reputation: 407
JGit might have what you're looking for, specifically http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/notes/NoteMap.html.
For instance, looking up the note for a specific commit can be done with:
Repository repo = ...
RevWalk walk = new RevWalk(repo);
NoteMap map = NoteMap.newEmptyMap();
Ref ref = repo.getRef("refs/notes/commits");
if (ref != null) {
RevCommit notesCommit = walk.parseCommit(ref.getObjectId());
map = NoteMap.read(walk.getObjectReader(), notesCommit);
map.getNote(notesCommit.getId());
}
Upvotes: 1