aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
diff options
context:
space:
mode:
authorMohamed Zenadi <mohamed@zenadi.com>2015-04-19 20:27:30 +0200
committerMohamed Zenadi <mohamed@zenadi.com>2015-04-19 20:27:30 +0200
commit771d8a9415831b5d6fe9cebf574fbf7e5eacd373 (patch)
tree3c74a84dce73e1e19b93839b803f509feabe36df /app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
parent6983ef4f82a85cae1e7f83638ce2f5ec37e96ef0 (diff)
downloadHardenedPass-771d8a9415831b5d6fe9cebf574fbf7e5eacd373.tar.gz
HardenedPass-771d8a9415831b5d6fe9cebf574fbf7e5eacd373.zip
Add a Sync command that calls Pull then Push
Fixes #78
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java47
1 files changed, 20 insertions, 27 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
index 0db20811..76599c3b 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java
@@ -25,11 +25,7 @@ import com.zeapo.pwdstore.R;
import com.zeapo.pwdstore.UserPreference;
import com.zeapo.pwdstore.utils.PasswordRepository;
-import org.eclipse.jgit.api.CloneCommand;
-import org.eclipse.jgit.api.Git;
-
import org.apache.commons.io.FileUtils;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
import java.io.File;
import java.io.IOException;
@@ -59,6 +55,7 @@ public class GitActivity extends ActionBarActivity {
public static final int REQUEST_CLONE = 103;
public static final int REQUEST_INIT = 104;
public static final int EDIT_SERVER = 105;
+ public static final int REQUEST_SYNC = 106;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -260,11 +257,15 @@ public class GitActivity extends ActionBarActivity {
break;
case REQUEST_PULL:
- pullFromRepository();
+ syncRepository(REQUEST_PULL);
break;
case REQUEST_PUSH:
- pushToRepository();
+ syncRepository(REQUEST_PUSH);
+ break;
+
+ case REQUEST_SYNC:
+ syncRepository(REQUEST_SYNC);
break;
}
@@ -521,20 +522,6 @@ public class GitActivity extends ActionBarActivity {
}
/**
- * Pull the latest changes from the remote repository and merges them locally
- */
- public void pullFromRepository() {
- syncRepository(REQUEST_PULL);
- }
-
- /**
- * Pushes the latest changes from the local repository to the remote one
- */
- public void pushToRepository() {
- syncRepository(REQUEST_PUSH);
- }
-
- /**
* Syncs the local repository with the remote one (either pull or push)
* @param operation the operation to execute can be REQUEST_PULL or REQUEST_PUSH
*/
@@ -566,13 +553,19 @@ public class GitActivity extends ActionBarActivity {
PasswordRepository.addRemote("origin", hostname, false);
GitOperation op;
- if (operation == REQUEST_PULL) {
- op = new PullOperation(localDir, activity).setCommand();
- } else if (operation == REQUEST_PUSH) {
- op = new PushOperation(localDir, activity).setCommand();
- } else {
- Log.e(TAG, "Sync operation not recognized : " + operation);
- return;
+ switch (operation) {
+ case REQUEST_PULL:
+ op = new PullOperation(localDir, activity).setCommand();
+ break;
+ case REQUEST_PUSH:
+ op = new PushOperation(localDir, activity).setCommand();
+ break;
+ case REQUEST_SYNC:
+ op = new SyncOperation(localDir, activity).setCommands();
+ break;
+ default:
+ Log.e(TAG, "Sync operation not recognized : " + operation);
+ return;
}
try {