我想使用Java从我有令牌的私人仓库中下载拉取请求。
阅读Jgit,我没有找到方法。
有人对此有想法吗?
答案 0 :(得分:0)
从link,您可以阅读有关此问题的更多信息。
private String localPath;
private Repository localRepo;
private Git git;
localPath = "/home/test/git_repo_test";
remotePath = "https://github.com/test/repo_1.git";
try {
localRepo = new FileRepository(localPath + "/.git");
} catch (IOException e) {
e.printStackTrace();
}
git = new Git(localRepo);
PullCommand pullCmd = git.pull();
try {
pullCmd.call();
PullResult result = pullCmd.call();
FetchResult fetchResult = result.getFetchResult();
MergeResult mergeResult = result.getMergeResult();
mergeResult.getMergeStatus(); // this should be interesting
} catch (GitAPIException e) {
e.printStackTrace();
}