diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2020-10-13 08:14:14 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2020-10-13 08:14:14 -0400 |
commit | 88e924e86beaa7e4911f4496e847a10833ac1c15 (patch) | |
tree | 80b815afc664c9497899375223b2b4d8e4823519 /org.eclipse.jgit.test | |
parent | f37aa182e14179479daf8a3a2a8240cd51912af1 (diff) | |
parent | 276fcb2a11aafbec488ac57de7c01ab7932762d9 (diff) | |
download | jgit-88e924e86beaa7e4911f4496e847a10833ac1c15.tar.gz jgit-88e924e86beaa7e4911f4496e847a10833ac1c15.zip |
Merge "Implement git describe --all"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java index 7ba7c8d2be..b460e3f52e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java @@ -310,7 +310,7 @@ public class DescribeCommandTest extends RepositoryTestCase { assertEquals( "2 commits for describe commit increment expected since lightweight tag: c4 and c3", "t2-2-g119892b", describe(c4)); // 2 commits: c4 and c3 - } else if (!useAnnotatedTags && !describeUseAllTags) { + } else if (!useAnnotatedTags) { assertEquals("no matching commits expected", null, describe(c4)); } else { assertEquals( @@ -405,6 +405,46 @@ public class DescribeCommandTest extends RepositoryTestCase { } } + @Test + public void testDescribeUseAllRefsMaster() throws Exception { + final ObjectId c1 = modify("aaa"); + tag("t1"); + + if (useAnnotatedTags || describeUseAllTags) { + assertEquals("t1", describe(c1)); + } else { + assertEquals(null, describe(c1)); + } + assertEquals("heads/master", describeAll(c1)); + } + + /** + * Branch off from master and then tag + * + * <pre> + * c1 -+ -> c2 + * | + * +-> t1 + * </pre> + * @throws Exception + * */ + @Test + public void testDescribeUseAllRefsBranch() throws Exception { + final ObjectId c1 = modify("aaa"); + modify("bbb"); + + branch("b", c1); + final ObjectId c3 = modify("ccc"); + tag("t1"); + + if (!useAnnotatedTags && !describeUseAllTags) { + assertEquals(null, describe(c3)); + } else { + assertEquals("t1", describe(c3)); + } + assertEquals("heads/b", describeAll(c3)); + } + private ObjectId merge(ObjectId c2) throws GitAPIException { return git.merge().include(c2).call().getNewHead(); } @@ -444,6 +484,11 @@ public class DescribeCommandTest extends RepositoryTestCase { return describe(c1, false, false); } + private String describeAll(ObjectId c1) throws GitAPIException, IOException { + return git.describe().setTarget(c1).setTags(describeUseAllTags) + .setLong(false).setAlways(false).setAll(true).call(); + } + private String describe(ObjectId c1, String... patterns) throws Exception { return git.describe().setTarget(c1).setTags(describeUseAllTags) .setMatch(patterns).call(); |