]> source.dussan.org Git - jgit.git/commitdiff
Allow to set a CredentialsProvider on relevant API commands 27/2327/2
authorMathias Kinzler <mathias.kinzler@sap.com>
Tue, 25 Jan 2011 14:03:19 +0000 (15:03 +0100)
committerChris Aniszczyk <caniszczyk@gmail.com>
Tue, 25 Jan 2011 22:36:10 +0000 (16:36 -0600)
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>
org.eclipse.jgit/src/org/eclipse/jgit/api/FetchCommand.java
org.eclipse.jgit/src/org/eclipse/jgit/api/PushCommand.java

index f81d20f3106ae877fddae27c0239b7dfc9a218ae..e75e20fee73f8b45fc63fb3354b75d67fa29cafd 100644 (file)
@@ -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;
+       }
 }
index fc03a589848cab9e7a444fae42943e67313bf84e..6981f77b18b2c812d4f39d9ed385c344c114aa69 100644 (file)
@@ -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;
+       }
 }