summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src/org
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-02-22 13:21:49 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2017-04-27 09:19:08 +0200
commit005e5feb4ecd08c4e4d141a38b9e7942accb3212 (patch)
tree686086609d3a9c559614a90c033a4965b1416bd3 /org.eclipse.jgit.pgm/src/org
parent76e86f4e48c98e742be99adff3b8b43cff94263c (diff)
downloadjgit-005e5feb4ecd08c4e4d141a38b9e7942accb3212.tar.gz
jgit-005e5feb4ecd08c4e4d141a38b9e7942accb3212.zip
Clone: add --recurse-submodules option
Add the --recurse-submodules option on the command, which causes submodules to also be initialized and updated. Add a callback interface on CloneCommand and SubmoduleUpdateCommand to them to provide progress feedback for clone operations. Change-Id: I41b1668bc0d0bdfa46a9a89882c9657ea3063fc1 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java49
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java2
2 files changed, 48 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
index 04078287fb..ca5205a4e1 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Clone.java
@@ -44,11 +44,14 @@
package org.eclipse.jgit.pgm;
import java.io.File;
+import java.io.IOException;
import java.text.MessageFormat;
+import java.util.Collection;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
+import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.pgm.internal.CLIText;
@@ -58,7 +61,7 @@ import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_cloneRepositoryIntoNewDir")
-class Clone extends AbstractFetchCommand {
+class Clone extends AbstractFetchCommand implements CloneCommand.Callback {
@Option(name = "--origin", aliases = { "-o" }, metaVar = "metaVar_remoteName", usage = "usage_useNameInsteadOfOriginToTrackUpstream")
private String remoteName = Constants.DEFAULT_REMOTE_NAME;
@@ -74,6 +77,9 @@ class Clone extends AbstractFetchCommand {
@Option(name = "--quiet", usage = "usage_quiet")
private Boolean quiet;
+ @Option(name = "--recurse-submodules", usage = "usage_recurseSubmodules")
+ private boolean cloneSubmodules;
+
@Argument(index = 0, required = true, metaVar = "metaVar_uriish")
private String sourceUri;
@@ -109,13 +115,15 @@ class Clone extends AbstractFetchCommand {
CloneCommand command = Git.cloneRepository();
command.setURI(sourceUri).setRemote(remoteName).setBare(isBare)
- .setNoCheckout(noCheckout).setBranch(branch);
+ .setNoCheckout(noCheckout).setBranch(branch)
+ .setCloneSubmodules(cloneSubmodules);
command.setGitDir(gitdir == null ? null : new File(gitdir));
command.setDirectory(localNameF);
boolean msgs = quiet == null || !quiet.booleanValue();
if (msgs) {
- command.setProgressMonitor(new TextProgressMonitor(errw));
+ command.setProgressMonitor(new TextProgressMonitor(errw))
+ .setCallback(this);
outw.println(MessageFormat.format(
CLIText.get().cloningInto, localName));
outw.flush();
@@ -136,4 +144,39 @@ class Clone extends AbstractFetchCommand {
outw.flush();
}
}
+
+ @Override
+ public void initializedSubmodules(Collection<String> submodules) {
+ try {
+ for (String submodule : submodules) {
+ outw.println(MessageFormat
+ .format(CLIText.get().submoduleRegistered, submodule));
+ }
+ outw.flush();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ @Override
+ public void cloningSubmodule(String path) {
+ try {
+ outw.println(MessageFormat.format(
+ CLIText.get().cloningInto, path));
+ outw.flush();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ @Override
+ public void checkingOut(AnyObjectId commit, String path) {
+ try {
+ outw.println(MessageFormat.format(CLIText.get().checkingOut,
+ path, commit.getName()));
+ outw.flush();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
index 4842b98731..e10ecbeebc 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java
@@ -121,6 +121,7 @@ public class CLIText extends TranslationBundle {
/***/ public String cantWrite;
/***/ public String changesNotStagedForCommit;
/***/ public String changesToBeCommitted;
+ /***/ public String checkingOut;
/***/ public String checkoutConflict;
/***/ public String checkoutConflictPathLine;
/***/ public String cleanRequireForce;
@@ -263,6 +264,7 @@ public class CLIText extends TranslationBundle {
/***/ public String statusDeletedByUs;
/***/ public String statusBothAdded;
/***/ public String statusBothModified;
+ /***/ public String submoduleRegistered;
/***/ public String switchedToNewBranch;
/***/ public String switchedToBranch;
/***/ public String tagAlreadyExists;