aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git/operation
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-08-14 01:46:47 +0530
committerGitHub <noreply@github.com>2020-08-13 22:16:47 +0200
commit57f1c65fdfbac9acd5e4fce30a6d5ef131fa9728 (patch)
tree7add98aecbb8d6b14f104a08893a1a319b1ab216 /app/src/main/java/com/zeapo/pwdstore/git/operation
parent2732f9093e5d609db15426f157d580c9494b9f15 (diff)
downloadHardenedPass-57f1c65fdfbac9acd5e4fce30a6d5ef131fa9728.tar.gz
HardenedPass-57f1c65fdfbac9acd5e4fce30a6d5ef131fa9728.zip
Restore workaround for preventing empty commits (#1019)
* Revert "Add symlink support to JGit (#1016)" This reverts commit 5032696cec9da86c2ad97b9931e8d85feb18da0c. * Restore workaround for empty commits and document commands Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Update app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/operation')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/operation/ResetToRemoteOperation.kt5
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/operation/SyncOperation.kt6
2 files changed, 11 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/operation/ResetToRemoteOperation.kt b/app/src/main/java/com/zeapo/pwdstore/git/operation/ResetToRemoteOperation.kt
index f0aee212..0d0dc019 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/operation/ResetToRemoteOperation.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/operation/ResetToRemoteOperation.kt
@@ -18,9 +18,14 @@ import org.eclipse.jgit.api.ResetCommand
class ResetToRemoteOperation(fileDir: File, callingActivity: AppCompatActivity) : GitOperation(fileDir, callingActivity) {
override val commands = arrayOf(
+ // Stage all files
git.add().addFilepattern("."),
+ // Fetch everything from the origin remote
git.fetch().setRemote("origin"),
+ // Do a hard reset to the remote branch. Equivalent to git reset --hard origin/$remoteBranch
git.reset().setRef("origin/$remoteBranch").setMode(ResetCommand.ResetType.HARD),
+ // Force-create $remoteBranch if it doesn't exist. This covers the case where you switched
+ // branches from 'master' to anything else.
git.branchCreate().setName(remoteBranch).setForce(true),
)
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/operation/SyncOperation.kt b/app/src/main/java/com/zeapo/pwdstore/git/operation/SyncOperation.kt
index 223f2cd8..35b12810 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/operation/SyncOperation.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/operation/SyncOperation.kt
@@ -17,9 +17,15 @@ import java.io.File
class SyncOperation(fileDir: File, callingActivity: AppCompatActivity) : GitOperation(fileDir, callingActivity) {
override val commands = arrayOf(
+ // Stage all files
git.add().addFilepattern("."),
+ // Populate the changed files count
+ git.status(),
+ // Commit everything! If needed, obviously.
git.commit().setAll(true).setMessage("[Android Password Store] Sync"),
+ // Pull and rebase on top of the remote branch
git.pull().setRebase(true).setRemote("origin"),
+ // Push it all back
git.push().setPushAll().setRemote("origin"),
)