Handle new version of git_bindings

This changes the way the SSH keys are managed, they are no longer
managed by the git_bindings plugin and are instead just passed as
parameters. They are now saved in shared_prefs. This allows us to easily
have multiple ssh keys.

It also allows us to store the ssh keys in a more secure storage
location in the future.
This commit is contained in:
Vishesh Handa
2020-10-19 14:52:24 +02:00
parent 05be1ce397
commit 98c92a3fe1
8 changed files with 166 additions and 171 deletions

View File

@ -171,7 +171,12 @@ class GitNoteRepository {
Future<void> fetch() async {
try {
await _gitRepo.fetch("origin");
await _gitRepo.fetch(
remote: "origin",
publicKey: settings.sshPublicKey,
privateKey: settings.sshPrivateKey,
password: settings.sshPassword,
);
} on GitException catch (ex, stackTrace) {
Log.e("GitPull Failed", ex: ex, stacktrace: stackTrace);
}
@ -210,7 +215,12 @@ class GitNoteRepository {
} catch (_) {}
try {
await _gitRepo.push("origin");
await _gitRepo.push(
remote: "origin",
publicKey: settings.sshPublicKey,
privateKey: settings.sshPrivateKey,
password: settings.sshPassword,
);
} on GitException catch (ex, stackTrace) {
if (ex.cause == 'cannot push non-fastforwardable reference') {
await fetch();