summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test/tst/org/eclipse
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-04-09 22:49:58 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2023-04-12 13:56:55 +0200
commit0e9708803f8f78efbe53b9b19bd568d50b412b50 (patch)
tree24ba8af5b658e6a596619f4245e5014389254848 /org.eclipse.jgit.pgm.test/tst/org/eclipse
parent060dcf1ccab6c43e4d5cc19524fafa3e82e351e0 (diff)
downloadjgit-0e9708803f8f78efbe53b9b19bd568d50b412b50.tar.gz
jgit-0e9708803f8f78efbe53b9b19bd568d50b412b50.zip
[pgm] Implement git tag --contains option
Change-Id: I390bcd2c2c563d4b27e1369f09548be59ba7c111
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org/eclipse')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java43
1 files changed, 42 insertions, 1 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java
index e8d61a520c..26d617dd81 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/TagTest.java
@@ -9,24 +9,30 @@
*/
package org.eclipse.jgit.pgm;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Before;
import org.junit.Test;
public class TagTest extends CLIRepositoryTestCase {
private Git git;
+ private RevCommit initialCommit;
+
@Override
@Before
public void setUp() throws Exception {
super.setUp();
git = new Git(db);
- git.commit().setMessage("initial commit").call();
+ initialCommit = git.commit().setMessage("initial commit").call();
}
@Test
@@ -57,4 +63,39 @@ public class TagTest extends CLIRepositoryTestCase {
assertEquals("fatal: error: tag 'test' not found", e.getMessage());
}
}
+
+ @Test
+ public void testContains() throws Exception {
+ /* c3
+ * |
+ * v2 - c2 b2 - v1
+ * | |
+ * c1 b1
+ * \ /
+ * a
+ */
+ try (TestRepository<Repository> r = new TestRepository<>(
+ db)) {
+ RevCommit b1 = r.commit(initialCommit);
+ RevCommit b2 = r.commit(b1);
+ RevCommit c1 = r.commit(initialCommit);
+ RevCommit c2 = r.commit(c1);
+ RevCommit c3 = r.commit(c2);
+ r.update("refs/tags/v1", r.tag("v1", b2));
+ r.update("refs/tags/v2", r.tag("v1.1", c2));
+
+ assertArrayEquals(
+ new String[] { "v1", "v2", "" },
+ execute("git tag --contains " + initialCommit.name()));
+
+ assertArrayEquals(new String[] { "v1", "" },
+ execute("git tag --contains " + b1.name()));
+
+ assertArrayEquals(new String[] { "v2", "" },
+ execute("git tag --contains " + c1.name()));
+
+ assertArrayEquals(new String[] { "" },
+ execute("git tag --contains " + c3.name()));
+ }
+ }
}