Is there a way to test if anyone pushed to the remote repo using JGit from local repo?

StackOverflow https://stackoverflow.com/questions/22888559

  •  28-06-2023
  •  | 
  •  

I am designing a User interface in Java and I am trying to make my own buildbot like thing. So for that I want to create a function like buildbot's gitpoller in JGit. Is it possible?

有帮助吗?

解决方案

Yes, it's possible. You can use a FetchCommand and then inspect the FetchResult. Something like this:

Repository repository = FileRepositoryBuilder.create(gitDir);
Git git = Git.wrap(repository);
FetchResult result = git.fetch().call();
for (TrackingRefUpdate refUpdate : result.getTrackingRefUpdates()) {
    // ...
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top