本文整理汇总了Java中org.eclipse.jgit.revwalk.RevCommit.getParents方法的典型用法代码示例。如果您正苦于以下问题:Java RevCommit.getParents方法的具体用法?Java RevCommit.getParents怎么用?Java RevCommit.getParents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.revwalk.RevCommit
的用法示例。
在下文中一共展示了RevCommit.getParents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.eclipse.jgit.revwalk.RevCommit; //导入方法依赖的package包/类
private void process(String fullName, String branch, String folder, ProcessCommitFn processCommitFn) {
GitService gitService = new GitServiceImpl();
try (
Repository repository = gitService.cloneIfNotExists(folder, "https://github.com/" + fullName + ".git");
RevWalk walk = gitService.createAllRevsWalk(repository, branch);) {
DbRepository dbRepository = repositoryDao.findOneByFullName(fullName);
if (dbRepository == null) {
dbRepository = repositoryDao.save(new DbRepository(fullName));
}
for (RevCommit commit : walk) {
LocalDateTime ldt = LocalDateTime.ofEpochSecond(commit.getCommitTime(), 0, ZoneOffset.UTC);
int parentsCount = commit.getParents().length;
if (ldt.isAfter(LocalDateTime.of(2017, 1, 1, 0, 0)) && parentsCount == 1) {
String sha1 = commit.getId().getName();
DbCommit dbCommit = commitDao.findOneByRepositoryAndSha1(dbRepository, sha1);
if (dbCommit == null) {
dbCommit = commitDao.save(new DbCommit(dbRepository, sha1));
}
if (dbCommit.getAffectedFiles() == null) {
List<String> javaFiles = new ArrayList<>();
Map<String, String> renamed = new HashMap<>();
gitService.fileTreeDiff(repository, commit, javaFiles, javaFiles, renamed, false);
Set<String> distinctFiles = new HashSet<>(javaFiles);
dbCommit.setAffectedFiles(distinctFiles.size());
commitDao.save(dbCommit);
}
processCommitFn.processCommit(repository, commit, dbCommit);
}
}
gitService.checkout(repository, branch);
} catch (Exception e) {
e.printStackTrace(System.err);
}
}