Jgit-如何使用Jgit获取两个日期之间的合并提交列表?

时间:2017-08-09 09:26:33

标签: java eclipse git jenkins

我需要从上次Jenkins Build中提取的日期提交列表,并获取自该日期以来的合并提交列表。 到目前为止,我已编码以获取合并提交列表。只需要一个解决方案来在指定日期之间提取这些提交。 参考代码:

Caused by: java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzac; or its super classes (declaration of 'com.google.android.gms.common.internal.zzac' appears in /data/app/com.prin.gaurav.app-1/split_lib_dependencies_apk.apk:classes20.dex)

1 个答案:

答案 0 :(得分:1)

您可以LogCommand#setRevFilter(RevFilter)使用CommitTimeRevFilter#between(Date,Date),e。 G:

ObjectId masterId = git.getRepository().exactRef("refs/heads/master").getObjectId();
Date since = new SimpleDateFormat("yyyy-MM-dd").parse("2017-08-01");
Date until = new SimpleDateFormat("yyyy-MM-dd").parse("2017-08-10");
RevFilter between = CommitTimeRevFilter.between(since, until);
for (RevCommit commit : git.log().add(masterId).setRevFilter(between).call()) {
    System.out.println(  "* "
                       + commit.getId().getName()
                       + " "
                       + commit.getShortMessage());
}