From dea451157200a216b135551e203242f229aac082 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 2 Jan 2012 09:40:53 -0800 Subject: [PATCH] Extend TransportCommand in submodule add/update commands This allows all the settings of a TransportCommand to be configured on the clone commands that are run by submodule add/update Change-Id: I93bfe5a91d430200de8c7f1e32a60cb990aa58ea --- .../eclipse/jgit/api/SubmoduleAddCommand.java | 20 +++---------------- .../jgit/api/SubmoduleUpdateCommand.java | 20 +++---------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java index 0b5200481..ac81ccb45 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java @@ -57,7 +57,6 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.submodule.SubmoduleWalk; -import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.treewalk.filter.PathFilter; import org.eclipse.jgit.treewalk.filter.TreeFilter; @@ -72,7 +71,8 @@ import org.eclipse.jgit.treewalk.filter.TreeFilter; * href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html" * >Git documentation about submodules */ -public class SubmoduleAddCommand extends GitCommand { +public class SubmoduleAddCommand extends + TransportCommand { private String path; @@ -80,8 +80,6 @@ public class SubmoduleAddCommand extends GitCommand { private ProgressMonitor monitor; - private CredentialsProvider credentialsProvider; - /** * @param repo */ @@ -124,17 +122,6 @@ public class SubmoduleAddCommand extends GitCommand { return this; } - /** - * @param credentialsProvider - * the {@link CredentialsProvider} to use - * @return this command - */ - public SubmoduleAddCommand setCredentialsProvider( - final CredentialsProvider credentialsProvider) { - this.credentialsProvider = credentialsProvider; - return this; - } - /** * Is the configured already a submodule in the index? * @@ -164,12 +151,11 @@ public class SubmoduleAddCommand extends GitCommand { // Clone submodule repository File moduleDirectory = SubmoduleWalk.getSubmoduleDirectory(repo, path); CloneCommand clone = Git.cloneRepository(); + configure(clone); clone.setDirectory(moduleDirectory); clone.setURI(uri); if (monitor != null) clone.setProgressMonitor(monitor); - if (credentialsProvider != null) - clone.setCredentialsProvider(credentialsProvider); Repository subRepo = clone.call().getRepository(); // Save submodule URL to parent repository's config diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java index 72daa489e..f94b2099a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java @@ -60,7 +60,6 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.submodule.SubmoduleWalk; -import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.treewalk.filter.PathFilterGroup; /** @@ -70,12 +69,11 @@ import org.eclipse.jgit.treewalk.filter.PathFilterGroup; * href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html" * >Git documentation about submodules */ -public class SubmoduleUpdateCommand extends GitCommand> { +public class SubmoduleUpdateCommand extends + TransportCommand> { private ProgressMonitor monitor; - private CredentialsProvider credentialsProvider; - private final Collection paths; /** @@ -100,17 +98,6 @@ public class SubmoduleUpdateCommand extends GitCommand> { return this; } - /** - * @param credentialsProvider - * the {@link CredentialsProvider} to use - * @return this command - */ - public SubmoduleUpdateCommand setCredentialsProvider( - final CredentialsProvider credentialsProvider) { - this.credentialsProvider = credentialsProvider; - return this; - } - /** * Add repository-relative submodule path to initialize * @@ -143,12 +130,11 @@ public class SubmoduleUpdateCommand extends GitCommand> { // Clone repository is not present if (submoduleRepo == null) { CloneCommand clone = Git.cloneRepository(); + configure(clone); clone.setURI(url); clone.setDirectory(generator.getDirectory()); if (monitor != null) clone.setProgressMonitor(monitor); - if (credentialsProvider != null) - clone.setCredentialsProvider(credentialsProvider); submoduleRepo = clone.call().getRepository(); }