문제

I need to write a precommit hook for GIT where the about to be commited files are checked to see if they are formatted according to a specific eclipse formatter. For this I need to get the list of the files which are not yet commited and their contents. Can this be done using JGIT?

도움이 되었습니까?

해결책

AFAIK, commit hooks aren't yet implemented in JGit. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=299315

However, for examining the index, you can use the DirCache class. DirCache.read(Repository) returns the index for the given repository. You can then either use a TreeWalk to iterate over the entries or use getEntryCount() and getEntry().
You may also want to look at the unit tests to get further pointers on how to use the API.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top