有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Jgit对于给定的存储库,我们如何确定新提交的列表,以及每个提交来自哪个分支?

我尝试获取所有分支,并按如下方式提交每个分支:

Repository repo = getRepository();
//fBranchList is a list of branches in that repository
for (String branch : fBranchList) {
    ObjectId commitId = repo.resolve(branchName)
}

这种方法存在一些性能问题。因此,我希望所有提交都在一个存储库中,以及提交发起的相应分支(父分支)

我想到的另一个方法是:

Git git = Git.open(new File("path")) ;
Iterable<RevCommit> commits = git.log().all().call();

for (RevCommit commit : commits) {
    if(commit.getParentCount()>1 ){
        System.out.println("LogCommit: " + commit.getName());
}

但使用这种方法,我无法获得第一次提交的分支。 你能帮忙吗


共 (0) 个答案