2017-09-12 16 views
0
내가 여기

JGit힘내 주어진 JGit를 사용하여 노트를 읽는 방법 미트 샤

를 사용하여 저장소에 커밋을 특정의 사용자 정의 심판 refs/notes/abcd에서 망할 놈의주의 사항 정보를 읽으려고하고

내가 뭘하려 :

Repository repository = repositoryManager.openRepository(repoName); 
Git git = new Git(repository); 
ObjectId oid = repository.resolve("5740b142a7b5f66768a2d904b267dccaef1a095f"); 
Note note = git.notesShow().setNotesRef("refs/notes/abcd").setObjectId(oid).call(); 
ObjectLoader loader = repository.open(note.getData()); 
byte[] data = loader.getBytes(); 
System.out.println(new String(data, "utf-8")); 
나는 다음과 같은 컴파일 오류 얻을 :

error: incompatible types: org.eclipse.jgit.lib.ObjectId cannot be converted to org.eclipse.jgit.revwalk.RevObject

은 어떻게 RevObject 변수가 커밋 샤을 문자열 주어진 setObjectId()을 힘내을 통과합니까?

답변

1

RevWalk을 사용하면 개체 ID를 구문 분석 할 수 있으며 결과는 RevCommit이고 ShowNoteCommand으로 전달할 수 있습니다. https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler에서

RevCommit commit; 
try(RevWalk revWalk = new RevWalk(repository)) { 
    commit = revWalk.parseCommit(oid); 
} 

git.notesShow().setObjectId(commit)... 
+0

도 참조 바로 실행 예 : 예를 들어

/jgit/porcelain/AddAndListNoteOfCommit.java 내 [jgit-cookbook] (https://github.com/centic9/jgit-cookbook/)에 있습니다. – centic