set credential after they've been intialized
This commit is contained in:
parent
530453025c
commit
3ca806d699
4 changed files with 29 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue