aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm
diff options
context:
space:
mode:
authorOliver Lockwood <oliver.lockwood@cantab.net>2017-06-21 17:34:05 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2017-06-22 09:08:55 +0200
commit43672700e747c3f95b64871b125129c152b9fa20 (patch)
tree1a02fb37904a5cd317ba2231f75548077d485c12 /org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm
parent060f3699d473a977b86b2ad9d653df4c83e8b681 (diff)
downloadjgit-43672700e747c3f95b64871b125129c152b9fa20.tar.gz
jgit-43672700e747c3f95b64871b125129c152b9fa20.zip
Add --match option for `jgit describe` to CLI
This adds --match option for glob(7) matchers on git tags to jgit describe in CLI. Bug: 518377 Change-Id: I745988d565dd4391e8b3e5a91bbfbae575333819 Signed-off-by: Oliver Lockwood <oliver.lockwood@cantab.net>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DescribeTest.java52
1 files changed, 49 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DescribeTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DescribeTest.java
index 086e72e9a4..e97762d8d1 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DescribeTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DescribeTest.java
@@ -46,6 +46,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.Arrays;
@@ -71,6 +72,12 @@ public class DescribeTest extends CLIRepositoryTestCase {
git.tag().setName("v1.0").call();
}
+ private void secondCommit() throws Exception {
+ writeTrashFile("greeting", "Hello, world!");
+ git.add().addFilepattern("greeting").call();
+ git.commit().setMessage("2nd commit").call();
+ }
+
@Test
public void testNoHead() throws Exception {
assertEquals(CLIText.fatalError(CLIText.get().noNamesFound),
@@ -94,9 +101,7 @@ public class DescribeTest extends CLIRepositoryTestCase {
@Test
public void testDescribeCommit() throws Exception {
initialCommitAndTag();
- writeTrashFile("greeting", "Hello, world!");
- git.add().addFilepattern("greeting").call();
- git.commit().setMessage("2nd commit").call();
+ secondCommit();
assertArrayEquals(new String[] { "v1.0-1-g56f6ceb", "" },
execute("git describe"));
}
@@ -109,6 +114,47 @@ public class DescribeTest extends CLIRepositoryTestCase {
}
@Test
+ public void testDescribeCommitMatch() throws Exception {
+ initialCommitAndTag();
+ secondCommit();
+ assertArrayEquals(new String[] { "v1.0-1-g56f6ceb", "" },
+ execute("git describe --match v1.*"));
+ }
+
+ @Test
+ public void testDescribeCommitMatch2() throws Exception {
+ initialCommitAndTag();
+ secondCommit();
+ git.tag().setName("v2.0").call();
+ assertArrayEquals(new String[] { "v1.0-1-g56f6ceb", "" },
+ execute("git describe --match v1.*"));
+ }
+
+ @Test
+ public void testDescribeCommitMultiMatch() throws Exception {
+ initialCommitAndTag();
+ secondCommit();
+ git.tag().setName("v2.0.0").call();
+ git.tag().setName("v2.1.1").call();
+ assertArrayEquals("git yields v2.0.0", new String[] { "v2.0.0", "" },
+ execute("git describe --match v2.0* --match v2.1.*"));
+ }
+
+ @Test
+ public void testDescribeCommitNoMatch() throws Exception {
+ initialCommitAndTag();
+ writeTrashFile("greeting", "Hello, world!");
+ secondCommit();
+ try {
+ execute("git describe --match 1.*");
+ fail("git describe should not find any tag matching 1.*");
+ } catch (Die e) {
+ assertEquals("No names found, cannot describe anything.",
+ e.getMessage());
+ }
+ }
+
+ @Test
public void testHelpArgumentBeforeUnknown() throws Exception {
String[] output = execute("git describe -h -XYZ");
String all = Arrays.toString(output);