aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathias Kinzler2011-01-25 09:03:19 (EST)
committerChris Aniszczyk2011-01-25 17:36:10 (EST)
commit920ac08777d4048c06c8d7a3671d37c5ead5917f (patch)
treeb32c42692e27bbb2565dfa3dd4c579ec2284273c
parent832d3b838472103e143074f000e9c59fd4596fa4 (diff)
downloadjgit-920ac08777d4048c06c8d7a3671d37c5ead5917f.zip
jgit-920ac08777d4048c06c8d7a3671d37c5ead5917f.tar.gz
jgit-920ac08777d4048c06c8d7a3671d37c5ead5917f.tar.bz2
Allow to set a CredentialsProvider on relevant API commandsrefs/changes/27/2327/2
This is needed for commands that use Transport internally. Change-Id: I9417c85255b160723968c647063b9c7e05995ea4 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java11
2 files changed, 22 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
index f81d20f..e75e20f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
@@ -56,6 +56,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.Transport;
@@ -86,6 +87,8 @@ public class FetchCommand extends GitCommand<FetchResult> {
private int timeout;
+ private CredentialsProvider credentialsProvider;
+
/**
* @param repo
@@ -121,6 +124,7 @@ public class FetchCommand extends GitCommand<FetchResult> {
transport.setTimeout(timeout);
transport.setDryRun(dryRun);
transport.setFetchThin(thin);
+ transport.setCredentialsProvider(credentialsProvider);
try {
FetchResult result = transport.fetch(monitor, refSpecs);
@@ -318,4 +322,11 @@ public class FetchCommand extends GitCommand<FetchResult> {
return this;
}
+ /**
+ * @param credentialsProvider
+ * the {@link CredentialsProvider} to use
+ */
+ public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
+ this.credentialsProvider = credentialsProvider;
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
index fc03a58..6981f77 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java
@@ -59,6 +59,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.PushResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig;
@@ -91,6 +92,8 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
private int timeout;
+ private CredentialsProvider credentialsProvider;
+
/**
* @param repo
*/
@@ -136,6 +139,7 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
if (receivePack != null)
transport.setOptionReceivePack(receivePack);
transport.setDryRun(dryRun);
+ transport.setCredentialsProvider(credentialsProvider);
final Collection<RemoteRefUpdate> toPush = transport
.findRemoteRefUpdatesFor(refSpecs);
@@ -346,4 +350,11 @@ public class PushCommand extends GitCommand<Iterable<PushResult>> {
return this;
}
+ /**
+ * @param credentialsProvider
+ * the {@link CredentialsProvider} to use
+ */
+ public void setCredentialsProvider(CredentialsProvider credentialsProvider) {
+ this.credentialsProvider = credentialsProvider;
+ }
}