Browse Source

repo command: properly name the required 'path' argument

Fixes point 4 in bug 484951, where "jgit repo" or "jgit repo -h" dumps a
stack trace.

Bug: 484951
Change-Id: Ic8b362e07a40ad923dc9acde0c0983a1e7932a02
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
stable-4.3
Andrey Loskutov 9 years ago
parent
commit
c1b31b3f3b
  1. 24
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java
  2. 2
      org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java

24
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/RepoTest.java

@ -42,10 +42,13 @@
*/
package org.eclipse.jgit.pgm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Arrays;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.junit.JGitTestUtil;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
@ -97,6 +100,27 @@ public class RepoTest extends CLIRepositoryTestCase {
resolveRelativeUris();
}
@Test
public void testMissingPath() throws Exception {
assertEquals("fatal: Argument \"path\" is required",
execute("git repo")[0]);
}
/**
* See bug 484951: "git repo -h" should not print unexpected values
*
* @throws Exception
*/
@Test
public void testZombieHelpArgument() throws Exception {
String[] output = execute("git repo -h");
String all = Arrays.toString(output);
assertTrue("Unexpected help output: " + all,
all.contains("jgit repo"));
assertFalse("Unexpected help output: " + all,
all.contains("jgit repo VAL"));
}
@Test
public void testAddRepoManifest() throws Exception {
StringBuilder xmlContent = new StringBuilder();

2
org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Repo.java

@ -55,7 +55,7 @@ class Repo extends TextBuiltin {
@Option(name = "--groups", aliases = { "-g" }, usage = "usage_groups")
private String groups = "default"; //$NON-NLS-1$
@Argument(required = true, usage = "usage_pathToXml")
@Argument(required = true, metaVar = "metaVar_path", usage = "usage_pathToXml")
private String path;
@Option(name = "--record-remote-branch", usage = "usage_branches")

Loading…
Cancel
Save