aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorMohamed Zenadi <mohamed@zenadi.com>2016-12-30 23:44:52 +0100
committerMohamed Zenadi <mohamed@zenadi.com>2016-12-30 23:45:33 +0100
commitec96699a62eae97019de0ea698250c6c398510ae (patch)
tree3c04077b88ec3723b379f50b7f3d2bfbea709602 /app/src/main/java
parentf717d6507dce446eb40aaf01d8ffb16f2c1a30df (diff)
sync command now tries to commit before pull/push
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java
index 4b698075..6c7e637d 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/SyncOperation.java
@@ -6,6 +6,8 @@ import android.content.DialogInterface;
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.PullCommand;
import org.eclipse.jgit.api.PushCommand;
@@ -13,6 +15,8 @@ import org.eclipse.jgit.api.PushCommand;
import java.io.File;
public class SyncOperation extends GitOperation {
+ protected AddCommand addCommand;
+ protected CommitCommand commitCommand;
protected PullCommand pullCommand;
protected PushCommand pushCommand;
@@ -31,14 +35,11 @@ public class SyncOperation extends GitOperation {
* @return the current object
*/
public SyncOperation setCommands() {
- this.pullCommand = new Git(repository)
- .pull()
- .setRebase(true)
- .setRemote("origin");
- this.pushCommand = new Git(repository)
- .push()
- .setPushAll()
- .setRemote("origin");
+ Git git = new Git(repository);
+ this.addCommand = git.add().addFilepattern(".");
+ this.commitCommand = git.commit().setMessage("[Android Password Store] Sync");
+ this.pullCommand = git.pull().setRebase(true).setRemote("origin");
+ this.pushCommand = git.push().setPushAll().setRemote("origin");
return this;
}
@@ -48,7 +49,7 @@ public class SyncOperation extends GitOperation {
this.pullCommand.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