Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1.                 // Get all the commits
  2.                 Iterable<RevCommit> commits = gitRepo.log().all().call();
  3.                
  4.                 // Iterate over the single commit
  5.                 for (RevCommit commit : commits) {         
  6.                
  7.                     // a RevWalk allows to walk over commits based on some filtering that is defined
  8.                     try (RevWalk revWalk = new RevWalk(repository)) {
  9.                         // and using commit's tree find the path
  10.                         if (commit.getParentCount() > 0) {
  11.                         RevCommit headCommit = commit.getParent(0);
  12.                         FileOutputStream stdout = new FileOutputStream(FileDescriptor.out);
  13.                         try (DiffFormatter diffFormatter = new DiffFormatter(stdout)) {
  14.                             diffFormatter.setRepository(repository);
  15.                             for (DiffEntry entry : diffFormatter.scan(headCommit, commit)) {  
  16.                                     System.out.println(entry.getNewPath());
  17.                                 }
  18.                             }
  19.                         }
  20.  
  21.                         revWalk.dispose();
  22.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement