git:java git api用于从存储库中获取git notes

时间:2013-09-10 09:54:08

标签: java git

git是否有java api,它允许从存储库中获取git注释? 我看了http://server001.agilebackoffice.org/nexus/content/repositories/atlassian/com/xiplink/jira/git/jira-git-plugin/0.6/,但看起来它似乎不支持git笔记。任何想法在哪里寻找?

1 个答案:

答案 0 :(得分:1)

JGit可能包含您正在寻找的内容,特别是http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/notes/NoteMap.html

例如,查找特定提交的注释可以通过以下方式完成:

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());
}