summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/src
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-03-24 10:26:44 +0900
committerMatthias Sohn <matthias.sohn@sap.com>2017-06-11 12:24:12 +0200
commitb6f954ad426f91561b4aa09d7ba23652516e7b0a (patch)
tree2e17a47047fc0ef2b48aea04b6b1bbbeaa404569 /org.eclipse.jgit.pgm/src
parent325b51dbd4ada37ab8890f38f2bbc046ee9bb92e (diff)
downloadjgit-b6f954ad426f91561b4aa09d7ba23652516e7b0a.tar.gz
jgit-b6f954ad426f91561b4aa09d7ba23652516e7b0a.zip
Fetch: Add --recurse-submodules and --no-recurse-submodules options
Add options to control recursion into submodules on fetch. Add a callback interface on FetchCommand, to allow Fetch to display an update "Fetching submodule XYZ" for each submodule. Change-Id: Id805044b57289ee0f384b434aba1dbd2fd317e5b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm/src')
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java46
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/internal/CLIText.java2
3 files changed, 49 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
index 2cee2cb007..08ec0964fc 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AbstractFetchCommand.java
@@ -90,6 +90,9 @@ abstract class AbstractFetchCommand extends TextBuiltin {
}
}
showRemoteMessages(errw, r.getMessages());
+ for (FetchResult submoduleResult : r.submoduleResults().values()) {
+ showFetchResult(submoduleResult);
+ }
}
static void showRemoteMessages(ThrowingPrintWriter writer, String pkt) throws IOException {
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
index ed06733a44..5ed23b9ffa 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Fetch.java
@@ -45,11 +45,15 @@
package org.eclipse.jgit.pgm;
+import java.io.IOException;
+import java.text.MessageFormat;
import java.util.List;
import org.eclipse.jgit.api.FetchCommand;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.SubmoduleConfig.FetchRecurseSubmodulesMode;
+import org.eclipse.jgit.pgm.internal.CLIText;
import org.eclipse.jgit.lib.TextProgressMonitor;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
@@ -58,7 +62,7 @@ import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@Command(common = true, usage = "usage_updateRemoteRefsFromAnotherRepository")
-class Fetch extends AbstractFetchCommand {
+class Fetch extends AbstractFetchCommand implements FetchCommand.Callback {
@Option(name = "--timeout", metaVar = "metaVar_seconds", usage = "usage_abortConnectionIfNoActivity")
int timeout = -1;
@@ -96,6 +100,31 @@ class Fetch extends AbstractFetchCommand {
tags = Boolean.FALSE;
}
+ private FetchRecurseSubmodulesMode recurseSubmodules;
+
+ @Option(name = "--recurse-submodules", usage = "usage_recurseSubmodules")
+ void recurseSubmodules(String mode) {
+ if (mode == null || mode.isEmpty()) {
+ recurseSubmodules = FetchRecurseSubmodulesMode.YES;
+ } else {
+ for (FetchRecurseSubmodulesMode m : FetchRecurseSubmodulesMode
+ .values()) {
+ if (m.matchConfigValue(mode)) {
+ recurseSubmodules = m;
+ return;
+ }
+ }
+ throw die(MessageFormat
+ .format(CLIText.get().invalidRecurseSubmodulesMode, mode));
+ }
+ }
+
+ @Option(name = "--no-recurse-submodules", usage = "usage_noRecurseSubmodules")
+ void noRecurseSubmodules(@SuppressWarnings("unused")
+ final boolean ignored) {
+ recurseSubmodules = FetchRecurseSubmodulesMode.NO;
+ }
+
@Argument(index = 0, metaVar = "metaVar_uriish")
private String remote = Constants.DEFAULT_REMOTE_NAME;
@@ -124,12 +153,25 @@ class Fetch extends AbstractFetchCommand {
fetch.setThin(thin.booleanValue());
if (quiet == null || !quiet.booleanValue())
fetch.setProgressMonitor(new TextProgressMonitor(errw));
+ fetch.setRecurseSubmodules(recurseSubmodules).setCallback(this);
FetchResult result = fetch.call();
- if (result.getTrackingRefUpdates().isEmpty())
+ if (result.getTrackingRefUpdates().isEmpty()
+ && result.submoduleResults().isEmpty())
return;
showFetchResult(result);
}
}
+
+ @Override
+ public void fetchingSubmodule(String name) {
+ try {
+ outw.println(MessageFormat.format(CLIText.get().fetchingSubmodule,
+ name));
+ 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 e10ecbeebc..e012372b92 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
@@ -143,12 +143,14 @@ public class CLIText extends TranslationBundle {
/***/ public String failedToLockTag;
/***/ public String fatalError;
/***/ public String fatalThisProgramWillDestroyTheRepository;
+ /***/ public String fetchingSubmodule;
/***/ public String fileIsRequired;
/***/ public String ffNotPossibleAborting;
/***/ public String forcedUpdate;
/***/ public String fromURI;
/***/ public String initializedEmptyGitRepositoryIn;
/***/ public String invalidHttpProxyOnlyHttpSupported;
+ /***/ public String invalidRecurseSubmodulesMode;
/***/ public String jgitVersion;
/***/ public String lfsNoAccessKey;
/***/ public String lfsNoSecretKey;