2

Is it possible to iterate through the list of commits remotely without having to clone the repo?

If no, what is/are the recommended approach to do so.

Use case: Display the list of commits on a web page and must always be up to date.

Sample output: expected output

Thank you.

Mincong Huang
  • 5,284
  • 8
  • 39
  • 62
redz0323
  • 56
  • 10

1 Answers1

0

Without cloning: that depends on the remote API proposed by the remote Git repos hosting server.

For example, GItHub has a GitHub API which can be used to list commits in a repo.
And it has a Java library (so, no JGit involved here)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • We are using kallithea, and I checked the kallithea API and appears to me that they does not provide such functionality. If you have an idea to do so will be much appreciated. Thank you once again. – redz0323 Apr 05 '18 at 05:18
  • @MarcRejohnCastillano Then you have other libraries to chose from: https://developer.github.com/v3/libraries/ – VonC Apr 05 '18 at 05:19
  • Correct me if I am wrong, are those API usable only if the repository exists in GitHub, right? Thank you. – redz0323 Apr 05 '18 at 05:36
  • Yes, my answer uses GitHub as an example of remote repo service. What is your as own current use case? – VonC Apr 05 '18 at 05:38
  • @MarcRejohnCastillano Then you need to use its client API: http://kallithea.readthedocs.io/en/stable/api/api.html#api-client, but it does not appear to include getting commits of a remote Git repo. – VonC Apr 05 '18 at 06:13
  • @MarcRejohnCastillano You would then need to code your own API listener on that kallithea server (if you control and manage it) in order to do that query for you and send you back the expected result. – VonC Apr 05 '18 at 06:14
  • Thank you so much for the suggestions. Helped a lot. God bless. – redz0323 Apr 05 '18 at 06:19
  • You can [iterate heads/branches/tags](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListRemoteRepository.java), with JGit you could download the repository into a temporary directory, do your work and delete it again, although that will take some time for larger repositories. – centic Apr 05 '18 at 18:35