aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-06-15 00:05:14 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2021-06-15 00:05:14 +0200
commit6a8afeb9f210f92e17b6c525d989c6072984289f (patch)
tree130a880a22b83ebfe8bdf3aa7db80b29c510929a /org.eclipse.jgit.pgm.test
parent1aa3cf7f416658a4fafd592732ba70f5a1aee19e (diff)
parent01b2c4fc90849f43042ffb0bb40fa3ab69541245 (diff)
downloadjgit-6a8afeb9f210f92e17b6c525d989c6072984289f.tar.gz
jgit-6a8afeb9f210f92e17b6c525d989c6072984289f.zip
Merge branch 'master' into next
* master: (47 commits) Fix @since from commit 64d0aaa2 Prepare 5.13.0-SNAPSHOT builds Prepare 5.12.1-SNAPSHOT builds Teach independent negotiation (no pack file) using an option "wait-for-done" JGit v5.12.0.202106070339-r [license-check] Update list of project dependencies [errorprone] Fix warning InputStreamSlowMultibyteRead [errorprone] Make operator precedence explicit in OpenSshConfigFile Update jetty to 9.4.41.v20210516 Prepare 5.1.17-SNAPSHOT builds JGit v5.1.16.202106041830-r Update Orbit to R20210602031627 Prepare 5.12.0-SNAPSHOT builds Fixing visibility for HostEntry constructors. JGit v5.12.0.202106021050-rc1 Prepare 5.12.0-SNAPSHOT builds JGit v5.12.0.202106011439-rc1 Clarify operator precedence to fix errorprone error Prepare 5.12.0-SNAPSHOT builds Update Orbit to S20210518003616 and ant to 1.10.10.v20210426-1926 ... Change-Id: I76a1f155201648a62df11a41a9e02d97f522d00f
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java
new file mode 100644
index 0000000000..06fddc29d9
--- /dev/null
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RevListTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2021, kylezhao <kylezhao@tencent.com> and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.pgm;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.CLIRepositoryTestCase;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RevListTest extends CLIRepositoryTestCase {
+
+ private Git git;
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ git = new Git(db);
+ }
+
+ @Test
+ public void testWithParentsFlag() throws Exception {
+ List<RevCommit> commits = createCommitsForParentsFlag(git);
+ String result = toString(
+ execute("git rev-list HEAD --parents -- Test.txt"));
+
+ String expect = toString(
+ commits.get(3).name() + ' ' + commits.get(1).name(),
+ commits.get(1).name());
+
+ assertEquals(expect, result);
+ }
+
+ @Test
+ public void testWithoutParentsFlag() throws Exception {
+ List<RevCommit> commits = createCommitsForParentsFlag(git);
+ String result = toString(execute("git rev-list HEAD -- Test.txt"));
+
+ String expect = toString(commits.get(3).name(), commits.get(1).name());
+
+ assertEquals(expect, result);
+ }
+
+ private List<RevCommit> createCommitsForParentsFlag(Git git)
+ throws Exception {
+ List<RevCommit> commits = new ArrayList<>();
+ writeTrashFile("Test1.txt", "Hello world");
+ git.add().addFilepattern("Test1.txt").call();
+ commits.add(git.commit().setMessage("commit#0").call());
+ writeTrashFile("Test.txt", "Hello world!");
+ git.add().addFilepattern("Test.txt").call();
+ commits.add(git.commit().setMessage("commit#1").call());
+ writeTrashFile("Test1.txt", "Hello world!!");
+ git.add().addFilepattern("Test1.txt").call();
+ commits.add(git.commit().setMessage("commit#2").call());
+ writeTrashFile("Test.txt", "Hello world!!!");
+ git.add().addFilepattern("Test.txt").call();
+ commits.add(git.commit().setMessage("commit#3").call());
+ return commits;
+ }
+}