Browse Source

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
stable-1.3
Kevin Sawicki 13 years ago
parent
commit
dea4511572
  1. 20
      org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java
  2. 20
      org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleUpdateCommand.java

20
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.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.submodule.SubmoduleWalk; 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.PathFilter;
import org.eclipse.jgit.treewalk.filter.TreeFilter; 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" * href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html"
* >Git documentation about submodules</a> * >Git documentation about submodules</a>
*/ */
public class SubmoduleAddCommand extends GitCommand<Repository> { public class SubmoduleAddCommand extends
TransportCommand<SubmoduleAddCommand, Repository> {
private String path; private String path;
@ -80,8 +80,6 @@ public class SubmoduleAddCommand extends GitCommand<Repository> {
private ProgressMonitor monitor; private ProgressMonitor monitor;
private CredentialsProvider credentialsProvider;
/** /**
* @param repo * @param repo
*/ */
@ -124,17 +122,6 @@ public class SubmoduleAddCommand extends GitCommand<Repository> {
return this; 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? * Is the configured already a submodule in the index?
* *
@ -164,12 +151,11 @@ public class SubmoduleAddCommand extends GitCommand<Repository> {
// Clone submodule repository // Clone submodule repository
File moduleDirectory = SubmoduleWalk.getSubmoduleDirectory(repo, path); File moduleDirectory = SubmoduleWalk.getSubmoduleDirectory(repo, path);
CloneCommand clone = Git.cloneRepository(); CloneCommand clone = Git.cloneRepository();
configure(clone);
clone.setDirectory(moduleDirectory); clone.setDirectory(moduleDirectory);
clone.setURI(uri); clone.setURI(uri);
if (monitor != null) if (monitor != null)
clone.setProgressMonitor(monitor); clone.setProgressMonitor(monitor);
if (credentialsProvider != null)
clone.setCredentialsProvider(credentialsProvider);
Repository subRepo = clone.call().getRepository(); Repository subRepo = clone.call().getRepository();
// Save submodule URL to parent repository's config // Save submodule URL to parent repository's config

20
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.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.submodule.SubmoduleWalk; import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup; 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" * href="http://www.kernel.org/pub/software/scm/git/docs/git-submodule.html"
* >Git documentation about submodules</a> * >Git documentation about submodules</a>
*/ */
public class SubmoduleUpdateCommand extends GitCommand<Collection<String>> { public class SubmoduleUpdateCommand extends
TransportCommand<SubmoduleUpdateCommand, Collection<String>> {
private ProgressMonitor monitor; private ProgressMonitor monitor;
private CredentialsProvider credentialsProvider;
private final Collection<String> paths; private final Collection<String> paths;
/** /**
@ -100,17 +98,6 @@ public class SubmoduleUpdateCommand extends GitCommand<Collection<String>> {
return this; 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 * Add repository-relative submodule path to initialize
* *
@ -143,12 +130,11 @@ public class SubmoduleUpdateCommand extends GitCommand<Collection<String>> {
// Clone repository is not present // Clone repository is not present
if (submoduleRepo == null) { if (submoduleRepo == null) {
CloneCommand clone = Git.cloneRepository(); CloneCommand clone = Git.cloneRepository();
configure(clone);
clone.setURI(url); clone.setURI(url);
clone.setDirectory(generator.getDirectory()); clone.setDirectory(generator.getDirectory());
if (monitor != null) if (monitor != null)
clone.setProgressMonitor(monitor); clone.setProgressMonitor(monitor);
if (credentialsProvider != null)
clone.setCredentialsProvider(credentialsProvider);
submoduleRepo = clone.call().getRepository(); submoduleRepo = clone.call().getRepository();
} }

Loading…
Cancel
Save