mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-01 06:45:19 +00:00
sync command now tries to commit before pull/push
This commit is contained in:
@@ -6,6 +6,8 @@ import android.content.DialogInterface;
|
|||||||
|
|
||||||
import com.zeapo.pwdstore.R;
|
import com.zeapo.pwdstore.R;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.api.AddCommand;
|
||||||
|
import org.eclipse.jgit.api.CommitCommand;
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.PullCommand;
|
import org.eclipse.jgit.api.PullCommand;
|
||||||
import org.eclipse.jgit.api.PushCommand;
|
import org.eclipse.jgit.api.PushCommand;
|
||||||
@@ -13,6 +15,8 @@ import org.eclipse.jgit.api.PushCommand;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class SyncOperation extends GitOperation {
|
public class SyncOperation extends GitOperation {
|
||||||
|
protected AddCommand addCommand;
|
||||||
|
protected CommitCommand commitCommand;
|
||||||
protected PullCommand pullCommand;
|
protected PullCommand pullCommand;
|
||||||
protected PushCommand pushCommand;
|
protected PushCommand pushCommand;
|
||||||
|
|
||||||
@@ -31,14 +35,11 @@ public class SyncOperation extends GitOperation {
|
|||||||
* @return the current object
|
* @return the current object
|
||||||
*/
|
*/
|
||||||
public SyncOperation setCommands() {
|
public SyncOperation setCommands() {
|
||||||
this.pullCommand = new Git(repository)
|
Git git = new Git(repository);
|
||||||
.pull()
|
this.addCommand = git.add().addFilepattern(".");
|
||||||
.setRebase(true)
|
this.commitCommand = git.commit().setMessage("[Android Password Store] Sync");
|
||||||
.setRemote("origin");
|
this.pullCommand = git.pull().setRebase(true).setRemote("origin");
|
||||||
this.pushCommand = new Git(repository)
|
this.pushCommand = git.push().setPushAll().setRemote("origin");
|
||||||
.push()
|
|
||||||
.setPushAll()
|
|
||||||
.setRemote("origin");
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ public class SyncOperation extends GitOperation {
|
|||||||
this.pullCommand.setCredentialsProvider(this.provider);
|
this.pullCommand.setCredentialsProvider(this.provider);
|
||||||
this.pushCommand.setCredentialsProvider(this.provider);
|
this.pushCommand.setCredentialsProvider(this.provider);
|
||||||
}
|
}
|
||||||
new GitAsyncTask(callingActivity, true, false, this).execute(this.pullCommand, this.pushCommand);
|
new GitAsyncTask(callingActivity, true, false, this).execute(this.addCommand, this.commitCommand, this.pullCommand, this.pushCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user