aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeapo <mohamed@zenadi.com>2014-12-18 21:52:38 +0100
committerzeapo <mohamed@zenadi.com>2015-01-04 14:53:59 +0100
commit3ca806d699182f3233c2425bd407988540083758 (patch)
tree7ce5ff71892fc8fcc9ab172fd4e4fcfcd834fc1e
parent530453025c1b0b90eb559e5480d57584b94ba661 (diff)
set credential after they've been intialized
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java10
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java4
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java14
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java12
4 files changed, 29 insertions, 11 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
index 3c5c20c6..dc94ce3b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/CloneOperation.java
@@ -4,7 +4,6 @@ import android.app.Activity;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import java.io.File;
@@ -27,7 +26,6 @@ public class CloneOperation extends GitOperation {
*/
public CloneOperation setCommand(String uri) {
this.command = Git.cloneRepository().
- setCredentialsProvider(provider).
setCloneAllBranches(true).
setDirectory(repository.getWorkTree()).
setURI(uri);
@@ -58,4 +56,12 @@ public class CloneOperation extends GitOperation {
super.setAuthentication(sshKey, username, passphrase);
return this;
}
+
+ @Override
+ public void execute() throws Exception {
+ if (this.provider != null) {
+ ((CloneCommand) this.command).setCredentialsProvider(this.provider);
+ }
+ new GitAsyncTask(callingActivity, true, false, CloneCommand.class).execute(this.command);
+ }
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
index 65436969..60112c90 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitOperation.java
@@ -78,9 +78,7 @@ public abstract class GitOperation {
*
* @throws Exception
*/
- public void execute() throws Exception {
- new GitAsyncTask(callingActivity, true, false, GitCommand.class).execute(command);
- }
+ public abstract void execute() throws Exception;
/**
* Executes the GitCommand in an async task after creating the authentication
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
index 0d43216d..2d499b4e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/PullOperation.java
@@ -2,9 +2,8 @@ package com.zeapo.pwdstore.git;
import android.app.Activity;
-import com.zeapo.pwdstore.utils.PasswordRepository;
-
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PullCommand;
import java.io.File;
@@ -29,8 +28,15 @@ public class PullOperation extends GitOperation {
this.command = new Git(repository)
.pull()
.setRebase(true)
- .setRemote("origin")
- .setCredentialsProvider(provider);
+ .setRemote("origin");
return this;
}
+
+ @Override
+ public void execute() throws Exception {
+ if (this.provider != null) {
+ ((PullCommand) this.command).setCredentialsProvider(this.provider);
+ }
+ new GitAsyncTask(callingActivity, true, false, PullCommand.class).execute(this.command);
+ }
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
index fa3e4dd9..fd4fb229 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/PushOperation.java
@@ -3,6 +3,7 @@ package com.zeapo.pwdstore.git;
import android.app.Activity;
import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PushCommand;
import java.io.File;
@@ -27,8 +28,15 @@ public class PushOperation extends GitOperation {
this.command = new Git(repository)
.push()
.setPushAll()
- .setRemote("origin")
- .setCredentialsProvider(provider);
+ .setRemote("origin");
return this;
}
+
+ @Override
+ public void execute() throws Exception {
+ if (this.provider != null) {
+ ((PushCommand) this.command).setCredentialsProvider(this.provider);
+ }
+ new GitAsyncTask(callingActivity, true, false, PushCommand.class).execute(this.command);
+ }
}