3

The statistics I want to pull about a repository include those offered by the Github statistics API https://developer.github.com/v3/repos/statistics/

My question is, is this possible using the library JGit?

From my research using stack over flow and Google, there is little, if any information that is clear about this. At this point I am doing research prior to starting a project, so example lines of code or even a guaranteed yes\no answer from experienced users is appreciated.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
user3904388
  • 103
  • 8

1 Answers1

0

As long as the repository holds the information you are looking for, it can be retrieved by using the JGit API.

A RevWalk can be used to traverse the commits of a repository and a TreeWalk in can be used to iterate the tree of a commit, i.e. the list of files the commit consists of. With a DiffFormatter, two commits can be compared and a list of DiffEntrys can be obtained that describe the added, removed and modified files.

Some time ago I wrote an article that might also be of interest. It touches the JGit APIs to read and write Git objects (commits, trees and blobs).

You may also want to look into gitective: a library that provides an API on top of JGit to make investigating Git repositories simpler and easier. While the project is unmaintained in the meanwhile it may either still work or can at least be used to learn how to use certain JGit APIs.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
  • Okay thanks! On another note, is it possible to read statistics from a repository (via URL) without cloning? – user3904388 Sep 26 '15 at 17:27
  • To do anything meaningful with a Git repository, you have to clone it first. This is not a limitation of JGit but inherent to the design of Git. Any operation other than synchronizing a repository with its remote requires a local copy. – Rüdiger Herrmann Sep 26 '15 at 18:28
  • Thanks, ive been looking into extracting repository issues. is this possible using jgit? i cant find any examples of this – user3904388 Sep 27 '15 at 11:51
  • I am afraid I don't understand. What are 'repository issues' and what does 'extracting' them mean? – Rüdiger Herrmann Sep 28 '15 at 09:55
  • I mean things like known bugs associated with projects on github, can jgit get that information. – user3904388 Sep 28 '15 at 13:16
  • No, JGit is a Java implementation of the Git version control system. See this page: https://developer.github.com/libraries/ for an overview of language bindings for the GitHub REST API. – Rüdiger Herrmann Sep 28 '15 at 14:20
  • Ah understand now, your help is appreciated – user3904388 Sep 29 '15 at 14:05
  • @RüdigerHerrmann I have a question http://stackoverflow.com/questions/40795781/how-to-write-git-log-stat-command-in-jgit would you mind to give it a shot. thx – Maytham Fahmi Nov 25 '16 at 08:52