diff options
Diffstat (limited to 'app/src/main/java')
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() - } - } - } } } |