summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-08-22 18:13:06 +0530
committerGitHub <noreply@github.com>2020-08-22 18:13:06 +0530
commit70aa41ae61fdfae1cbf2093cd5848c5808b08013 (patch)
treefe453fd36ab6716365cf0e4fd0627dfbcefe62f4 /app/src/main/java
parent70f7d3b199a1a11084c23c2a1545b7bacce70258 (diff)
Don't use git config for setting author and email (#1043)
Fixes #1038 Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt6
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt2
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt42
3 files changed, 5 insertions, 45 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt
index e98f66ad..bf35e5c7 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitCommandExecutor.kt
@@ -14,6 +14,7 @@ import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.git.GitException.PullException
import com.zeapo.pwdstore.git.GitException.PushException
+import com.zeapo.pwdstore.git.config.GitSettings
import com.zeapo.pwdstore.git.sshj.SshjSessionFactory
import com.zeapo.pwdstore.git.operation.GitOperation
import com.zeapo.pwdstore.utils.Result
@@ -28,6 +29,7 @@ import org.eclipse.jgit.api.PullCommand
import org.eclipse.jgit.api.PushCommand
import org.eclipse.jgit.api.RebaseResult
import org.eclipse.jgit.api.StatusCommand
+import org.eclipse.jgit.lib.PersonIdent
import org.eclipse.jgit.transport.RemoteRefUpdate
import org.eclipse.jgit.transport.SshSessionFactory
@@ -60,7 +62,9 @@ class GitCommandExecutor(
// the previous status will eventually be used to avoid a commit
if (nbChanges > 0) {
withContext(Dispatchers.IO) {
- command.call()
+ command
+ .setAuthor(PersonIdent(GitSettings.authorName, GitSettings.authorEmail))
+ .call()
}
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt
index 5138b50b..9205e7fc 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitConfigActivity.kt
@@ -61,8 +61,6 @@ class GitConfigActivity : BaseGitActivity() {
} else {
GitSettings.authorEmail = email
GitSettings.authorName = name
- PasswordRepository.setGitAuthorEmail(email)
- PasswordRepository.setGitAuthorName(name)
Snackbar.make(binding.root, getString(R.string.git_server_config_save_success), Snackbar.LENGTH_SHORT).show()
Handler().postDelayed(500) { finish() }
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
index 45453d4f..f0b891fc 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.kt
@@ -244,47 +244,5 @@ open class PasswordRepository protected constructor() {
passwordList.sortWith(sortOrder.comparator)
return passwordList
}
-
- /**
- * Sets the git user name
- *
- * @param username username
- */
- @JvmStatic
- fun setGitAuthorName(username: String) {
- setStringConfig("user", null, "name", username)
- }
-
- /**
- * Sets the git user email
- *
- * @param email email
- */
- @JvmStatic
- fun setGitAuthorEmail(email: String) {
- setStringConfig("user", null, "email", email)
- }
-
- /**
- * Sets a git config value
- *
- * @param section config section name
- * @param subsection config subsection name
- * @param name config name
- * @param value the value to be set
- */
- @JvmStatic
- @Suppress("SameParameterValue")
- private fun setStringConfig(section: String, subsection: String?, name: String, value: String) {
- if (isInitialized) {
- val config = repository!!.config
- config.setString(section, subsection, name, value)
- try {
- config.save()
- } catch (e: Exception) {
- e.printStackTrace()
- }
- }
- }
}
}