diff options
Diffstat (limited to 'app/src/main/java')
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); + } } |