After digging around a bit, I decided to go with the Kohsuke github library instead. When doing that it was quite straightforward. Posting basic code example for reference. (Please note that this if for Enterprise Git. If you are doing it for "normal" Git, look into the Kohsuke documentation, you will need to use another method instead of connectToEnterpriseWithOAuth.)
import org.kohsuke.github.*;
public class GitIntegration {
public GitIntegration() {
}
public String getCommits(String repo) {
String retval = "";
try {
GitHub gitHub = GitHub.connectToEnterpriseWithOAuth("https://git.our.company.com/api/v3", "[email protected]", "xyzxyzTokenxyzxyz");
GHMyself me = gitHub.getMyself();
GHRepository repository = gitHub.getRepository("Gituser/"+repo);
Calendar cal = Calendar.getInstance();
cal.set(2020, 10, 4);
Date since = cal.getTime();
GHCommitQueryBuilder queryBuilder = repository.queryCommits().since(since).until(new Date());
PagedIterable<GHCommit> commits = queryBuilder.list();
Iterator<GHCommit> iterator = commits.iterator();
while (iterator.hasNext()) {
GHCommit commit = iterator.next();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
GHUser user = commit.getAuthor();
String name = "";
if(user != null) name = user.getName();
String message = commit.getCommitShortInfo().getMessage();
retval = retval.concat(message + " | " + name + " | " + sdf.format(commit.getCommitDate()) + "
");
}
} catch (IOException e) {
// TODO Auto-generated catch block
retval = e.getCause().getMessage();
e.printStackTrace();
}
return retval;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…