Add GitConfig

This makes the Settings class smaller.
This commit is contained in:
Vishesh Handa
2021-07-26 20:17:45 +02:00
parent b08c4436b7
commit b2e08550bb
9 changed files with 153 additions and 113 deletions

View File

@ -8,6 +8,7 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:easy_localization_loader/easy_localization_loader.dart';
import 'package:flutter_runtime_env/flutter_runtime_env.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'package:provider/provider.dart';
@ -372,13 +373,16 @@ class GitJournalChangeNotifiers extends StatelessWidget {
child: ChangeNotifierProvider.value(
value: repoManager.currentRepo,
child: Consumer<GitJournalRepo>(
builder: (_, repo, __) => ChangeNotifierProvider<Settings>.value(
value: repo.settings,
child: Consumer<GitJournalRepo>(
builder: (_, repo, __) =>
ChangeNotifierProvider<NotesFolderFS>.value(
value: repo.notesFolder,
child: child,
builder: (_, repo, __) => ChangeNotifierProvider<GitConfig>.value(
value: repo.gitConfig,
child: ChangeNotifierProvider<Settings>.value(
value: repo.settings,
child: Consumer<GitJournalRepo>(
builder: (_, repo, __) =>
ChangeNotifierProvider<NotesFolderFS>.value(
value: repo.notesFolder,
child: child,
),
),
),
),

View File

@ -11,7 +11,7 @@ import 'package:gitjournal/core/notes_folder.dart';
import 'package:gitjournal/core/notes_folder_fs.dart';
import 'package:gitjournal/error_reporting.dart';
import 'package:gitjournal/settings/app_settings.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/utils/git_desktop.dart';
import 'package:gitjournal/utils/logger.dart';
@ -20,11 +20,11 @@ bool useDartGit = false;
class GitNoteRepository {
final String gitDirPath;
final gb.GitRepo _gitRepo;
final Settings settings;
final GitConfig config;
GitNoteRepository({
required this.gitDirPath,
required this.settings,
required this.config,
}) : _gitRepo = gb.GitRepo(folderPath: gitDirPath) {
// git-bindings aren't properly implemented in these platforms
if (Platform.isLinux || Platform.isMacOS || Platform.isWindows) {
@ -79,8 +79,8 @@ class GitNoteRepository {
try {
await _gitRepo.commit(
message: message,
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
);
} on Exception catch (ex, st) {
return Result.fail(ex, st);
@ -103,8 +103,8 @@ class GitNoteRepository {
var res = await _commit(
message: commitMessage,
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
);
if (res.isFailure) {
return fail(r);
@ -160,8 +160,8 @@ class GitNoteRepository {
await _rm(spec).throwOnError();
await _commit(
message: "Removed Note " + spec,
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
).throwOnError();
return Result(null);
@ -174,8 +174,8 @@ class GitNoteRepository {
await _rm(spec).throwOnError();
await _commit(
message: "Removed Folder " + spec,
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
).throwOnError();
return Result(null);
@ -216,9 +216,9 @@ class GitNoteRepository {
try {
await _gitRepo.fetch(
remote: remoteName,
publicKey: settings.sshPublicKey,
privateKey: settings.sshPrivateKey,
password: settings.sshPassword,
publicKey: config.sshPublicKey,
privateKey: config.sshPrivateKey,
password: config.sshPassword,
statusFile: p.join(Directory.systemTemp.path, 'gj'),
);
} on gb.GitException catch (ex, stackTrace) {
@ -229,8 +229,8 @@ class GitNoteRepository {
}
} else if (Platform.isMacOS) {
await gitPushViaExecutable(
privateKey: settings.sshPrivateKey,
privateKeyPassword: settings.sshPassword,
privateKey: config.sshPrivateKey,
privateKeyPassword: config.sshPassword,
remoteName: remoteName,
repoPath: gitDirPath,
).throwOnError();
@ -263,8 +263,8 @@ class GitNoteRepository {
if (useDartGit || AppSettings.instance.experimentalGitMerge) {
var author = GitAuthor(
email: settings.gitAuthorEmail,
name: settings.gitAuthor,
email: config.gitAuthorEmail,
name: config.gitAuthor,
);
return repo.mergeCurrentTrackingBranch(author: author);
}
@ -272,8 +272,8 @@ class GitNoteRepository {
try {
await _gitRepo.merge(
branch: branchConfig.remoteTrackingBranch(),
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
);
} on gb.GitException catch (ex, stackTrace) {
Log.e("Git Merge Failed", ex: ex, stacktrace: stackTrace);
@ -300,9 +300,9 @@ class GitNoteRepository {
try {
await _gitRepo.push(
remote: remoteName,
publicKey: settings.sshPublicKey,
privateKey: settings.sshPrivateKey,
password: settings.sshPassword,
publicKey: config.sshPublicKey,
privateKey: config.sshPrivateKey,
password: config.sshPassword,
statusFile: p.join(Directory.systemTemp.path, 'gj'),
);
} on gb.GitException catch (ex, stackTrace) {
@ -316,8 +316,8 @@ class GitNoteRepository {
}
} else if (Platform.isMacOS) {
await gitPushViaExecutable(
privateKey: settings.sshPrivateKey,
privateKeyPassword: settings.sshPassword,
privateKey: config.sshPrivateKey,
privateKeyPassword: config.sshPassword,
remoteName: remoteName,
repoPath: gitDirPath,
).throwOnError();

View File

@ -20,6 +20,7 @@ import 'package:gitjournal/core/note.dart';
import 'package:gitjournal/core/notes_cache.dart';
import 'package:gitjournal/core/notes_folder_fs.dart';
import 'package:gitjournal/error_reporting.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/settings/settings_migrations.dart';
import 'package:gitjournal/utils/logger.dart';
@ -34,6 +35,7 @@ enum SyncStatus {
class GitJournalRepo with ChangeNotifier {
final Settings settings;
final GitConfig gitConfig;
final _opLock = Lock();
final _loadLock = Lock();
@ -76,6 +78,9 @@ class GitJournalRepo with ChangeNotifier {
Log.i("Setting ${settings.toLoggableMap()}");
var gitConfig = GitConfig(id);
gitConfig.load(pref);
var repoPath = await settings.buildRepoPath(gitBaseDir);
Log.i("Loading Repo at path $repoPath");
@ -107,6 +112,7 @@ class GitJournalRepo with ChangeNotifier {
cacheDir: cacheDir,
remoteGitRepoConfigured: remoteConfigured,
settings: settings,
gitConfig: gitConfig,
id: id,
currentBranch: await repo.currentBranch().getOrThrow(),
);
@ -118,10 +124,11 @@ class GitJournalRepo with ChangeNotifier {
required this.gitBaseDirectory,
required this.cacheDir,
required this.settings,
required this.gitConfig,
required this.remoteGitRepoConfigured,
required String? currentBranch,
}) {
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
_gitRepo = GitNoteRepository(gitDirPath: repoPath, config: gitConfig);
notesFolder = NotesFolderFS(null, _gitRepo.gitDirPath, settings);
_currentBranch = currentBranch;
@ -408,9 +415,9 @@ class GitJournalRepo with ChangeNotifier {
repoPath = p.join(gitBaseDirectory, repoFolderName);
Log.i("repoPath: $repoPath");
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
_gitRepo = GitNoteRepository(gitDirPath: repoPath, config: gitConfig);
await _addFileInRepo(repo: this, settings: settings);
await _addFileInRepo(repo: this, config: gitConfig);
_notesCache.clear();
remoteGitRepoConfigured = true;
@ -442,7 +449,7 @@ class GitJournalRepo with ChangeNotifier {
await Directory(repoPath).delete(recursive: true);
repoPath = newRepoPath;
_gitRepo = GitNoteRepository(gitDirPath: repoPath, settings: settings);
_gitRepo = GitNoteRepository(gitDirPath: repoPath, config: gitConfig);
_notesCache.clear();
notesFolder.reset(repoPath);
@ -560,7 +567,7 @@ Future<void> _copyDirectory(String source, String destination) async {
/// one commit. It makes doing a git pull and push easier
Future<void> _addFileInRepo({
required GitJournalRepo repo,
required Settings settings,
required GitConfig config,
}) async {
var repoPath = repo.repoPath;
var dirList = await Directory(repoPath).list().toList();
@ -577,8 +584,8 @@ Future<void> _addFileInRepo({
await repo.commit(
message: "Add gitignore file",
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
authorEmail: config.gitAuthorEmail,
authorName: config.gitAuthor,
);
}
}

View File

@ -0,0 +1,50 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:gitjournal/settings/settings_sharedpref.dart';
class GitConfig extends ChangeNotifier with SettingsSharedPref {
GitConfig(this.id);
@override
final String id;
var gitAuthor = "GitJournal";
var gitAuthorEmail = "app@gitjournal.io";
var sshPublicKey = "";
var sshPrivateKey = "";
var sshPassword = "";
void load(SharedPreferences pref) {
gitAuthor = getString(pref, "gitAuthor") ?? gitAuthor;
gitAuthorEmail = getString(pref, "gitAuthorEmail") ?? gitAuthorEmail;
sshPublicKey = getString(pref, "sshPublicKey") ?? sshPublicKey;
sshPrivateKey = getString(pref, "sshPrivateKey") ?? sshPrivateKey;
sshPassword = getString(pref, "sshPassword") ?? sshPassword;
}
Future<void> save() async {
var pref = await SharedPreferences.getInstance();
var defaultSet = GitConfig(id);
await setString(pref, "gitAuthor", gitAuthor, defaultSet.gitAuthor);
await setString(
pref, "gitAuthorEmail", gitAuthorEmail, defaultSet.gitAuthorEmail);
await setString(
pref, "sshPublicKey", sshPublicKey, defaultSet.sshPublicKey);
await setString(
pref, "sshPrivateKey", sshPrivateKey, defaultSet.sshPrivateKey);
await setString(pref, "sshPassword", sshPassword, defaultSet.sshPassword);
}
Map<String, String> toLoggableMap() {
return <String, String>{
"gitAuthor": gitAuthor.isNotEmpty.toString(),
"gitAuthorEmail": gitAuthorEmail.isNotEmpty.toString(),
'sshPublicKey': sshPublicKey.isNotEmpty.toString(),
'sshPrivateKey': sshPrivateKey.isNotEmpty.toString(),
'sshPassword': sshPassword.isNotEmpty.toString(),
};
}
}

View File

@ -42,13 +42,6 @@ class Settings extends ChangeNotifier with SettingsSharedPref {
String folderName = "journal";
// Git Settings
String gitAuthor = "GitJournal";
String gitAuthorEmail = "app@gitjournal.io";
String sshPublicKey = "";
String sshPrivateKey = "";
String sshPassword = "";
NoteFileNameFormat noteFileNameFormat = NoteFileNameFormat.Default;
NoteFileNameFormat journalNoteFileNameFormat = NoteFileNameFormat.Default;
@ -97,12 +90,6 @@ class Settings extends ChangeNotifier with SettingsSharedPref {
String storageLocation = "";
void load(SharedPreferences pref) {
gitAuthor = getString(pref, "gitAuthor") ?? gitAuthor;
gitAuthorEmail = getString(pref, "gitAuthorEmail") ?? gitAuthorEmail;
sshPublicKey = getString(pref, "sshPublicKey") ?? sshPublicKey;
sshPrivateKey = getString(pref, "sshPrivateKey") ?? sshPrivateKey;
sshPassword = getString(pref, "sshPassword") ?? sshPassword;
noteFileNameFormat = NoteFileNameFormat.fromInternalString(
getString(pref, "noteFileNameFormat"));
journalNoteFileNameFormat = NoteFileNameFormat.fromInternalString(
@ -179,15 +166,6 @@ class Settings extends ChangeNotifier with SettingsSharedPref {
var pref = await SharedPreferences.getInstance();
var defaultSet = Settings(id);
await setString(pref, "gitAuthor", gitAuthor, defaultSet.gitAuthor);
await setString(
pref, "gitAuthorEmail", gitAuthorEmail, defaultSet.gitAuthorEmail);
await setString(
pref, "sshPublicKey", sshPublicKey, defaultSet.sshPublicKey);
await setString(
pref, "sshPrivateKey", sshPrivateKey, defaultSet.sshPrivateKey);
await setString(pref, "sshPassword", sshPassword, defaultSet.sshPassword);
await setString(
pref,
"noteFileNameFormat",
@ -278,10 +256,6 @@ class Settings extends ChangeNotifier with SettingsSharedPref {
Map<String, String> toLoggableMap() {
return <String, String>{
"gitAuthor": gitAuthor.isNotEmpty.toString(),
"gitAuthorEmail": gitAuthorEmail.isNotEmpty.toString(),
'sshPublicKey': sshPublicKey.isNotEmpty.toString(),
'sshPrivateKey': sshPrivateKey.isNotEmpty.toString(),
"noteFileNameFormat": noteFileNameFormat.toInternalString(),
"journalNoteFileNameFormat": journalNoteFileNameFormat.toInternalString(),
"yamlModifiedKey": yamlModifiedKey,

View File

@ -9,6 +9,7 @@ import 'package:path/path.dart' as p;
import 'package:provider/provider.dart';
import 'package:gitjournal/repository.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/settings/settings_widgets.dart';
import 'package:gitjournal/setup/screens.dart';
@ -163,15 +164,15 @@ class _GitRemoteSettingsScreenState extends State<GitRemoteSettingsScreen> {
}
void _updateKeys(String publicKey, String privateKey, String password) {
var settings = Provider.of<Settings>(context, listen: false);
var config = Provider.of<GitConfig>(context, listen: false);
if (publicKey.isEmpty || privateKey.isEmpty) {
return;
}
settings.sshPublicKey = publicKey;
settings.sshPrivateKey = privateKey;
settings.sshPassword = password;
settings.save();
config.sshPublicKey = publicKey;
config.sshPrivateKey = privateKey;
config.sshPassword = password;
config.save();
Navigator.of(context).pop();
}
@ -188,11 +189,11 @@ class _GitRemoteSettingsScreenState extends State<GitRemoteSettingsScreen> {
DateTime.now().toIso8601String().substring(0, 10); // only the date
generateSSHKeys(comment: comment).then((SshKey? sshKey) {
var settings = Provider.of<Settings>(context, listen: false);
settings.sshPublicKey = sshKey!.publicKey;
settings.sshPrivateKey = sshKey.publicKey;
settings.sshPassword = sshKey.password;
settings.save();
var config = Provider.of<GitConfig>(context, listen: false);
config.sshPublicKey = sshKey!.publicKey;
config.sshPrivateKey = sshKey.publicKey;
config.sshPassword = sshKey.password;
config.save();
Log.d("PublicKey: " + sshKey.publicKey);
_copyKeyToClipboard(context);

View File

@ -38,6 +38,7 @@ import 'package:gitjournal/repository_manager.dart';
import 'package:gitjournal/screens/debug_screen.dart';
import 'package:gitjournal/screens/feature_timeline_screen.dart';
import 'package:gitjournal/settings/app_settings.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/settings/settings_bottom_menu_bar.dart';
import 'package:gitjournal/settings/settings_display_images.dart';
@ -87,14 +88,15 @@ class SettingsListState extends State<SettingsList> {
@override
Widget build(BuildContext context) {
var settings = Provider.of<Settings>(context);
var gitConfig = Provider.of<GitConfig>(context);
var appSettings = Provider.of<AppSettings>(context);
final repo = Provider.of<GitJournalRepo>(context);
var repoManager = Provider.of<RepositoryManager>(context);
var saveGitAuthor = (String? gitAuthor) {
if (gitAuthor == null) return;
settings.gitAuthor = gitAuthor;
settings.save();
gitConfig.gitAuthor = gitAuthor;
gitConfig.save();
};
var gitAuthorForm = Form(
@ -116,7 +118,7 @@ class SettingsListState extends State<SettingsList> {
textInputAction: TextInputAction.done,
onFieldSubmitted: saveGitAuthor,
onSaved: saveGitAuthor,
initialValue: settings.gitAuthor,
initialValue: gitConfig.gitAuthor,
),
onChanged: () {
if (!gitAuthorKey.currentState!.validate()) return;
@ -128,8 +130,8 @@ class SettingsListState extends State<SettingsList> {
var saveGitAuthorEmail = (String? gitAuthorEmail) {
if (gitAuthorEmail == null) return;
settings.gitAuthorEmail = gitAuthorEmail;
settings.save();
gitConfig.gitAuthorEmail = gitAuthorEmail;
gitConfig.save();
};
var gitAuthorEmailForm = Form(
child: TextFormField(
@ -155,7 +157,7 @@ class SettingsListState extends State<SettingsList> {
textInputAction: TextInputAction.done,
onFieldSubmitted: saveGitAuthorEmail,
onSaved: saveGitAuthorEmail,
initialValue: settings.gitAuthorEmail,
initialValue: gitConfig.gitAuthorEmail,
),
onChanged: () {
if (!gitAuthorEmailKey.currentState!.validate()) return;
@ -270,7 +272,7 @@ class SettingsListState extends State<SettingsList> {
onTap: () {
var route = MaterialPageRoute(
builder: (context) =>
GitRemoteSettingsScreen(settings.sshPublicKey),
GitRemoteSettingsScreen(gitConfig.sshPublicKey),
settings: const RouteSettings(name: '/settings/gitRemote'),
);
Navigator.of(context).push(route);

View File

@ -8,7 +8,7 @@ import 'package:provider/provider.dart';
import 'package:gitjournal/analytics/analytics.dart';
import 'package:gitjournal/apis/githost_factory.dart';
import 'package:gitjournal/error_reporting.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/utils/logger.dart';
import 'button.dart';
import 'error.dart';
@ -65,14 +65,14 @@ class GitHostSetupAutoConfigurePageState
});
userInfo = await gitHost!.getUserInfo().getOrThrow();
var settings = Provider.of<Settings>(context, listen: false);
var gitConfig = Provider.of<GitConfig>(context, listen: false);
if (userInfo.name.isNotEmpty) {
settings.gitAuthor = userInfo.name;
gitConfig.gitAuthor = userInfo.name;
}
if (userInfo.email.isNotEmpty) {
settings.gitAuthorEmail = userInfo.email;
gitConfig.gitAuthorEmail = userInfo.email;
}
settings.save();
gitConfig.save();
} on Exception catch (e, stacktrace) {
_handleGitHostException(e, stacktrace);
return;

View File

@ -16,6 +16,7 @@ import 'package:gitjournal/analytics/analytics.dart';
import 'package:gitjournal/apis/githost_factory.dart';
import 'package:gitjournal/error_reporting.dart';
import 'package:gitjournal/repository.dart';
import 'package:gitjournal/settings/git_config.dart';
import 'package:gitjournal/settings/settings.dart';
import 'package:gitjournal/setup/autoconfigure.dart';
import 'package:gitjournal/setup/button.dart';
@ -225,11 +226,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
return GitHostUserProvidedKeysPage(
doneFunction:
(String publicKey, String privateKey, String password) async {
var settings = Provider.of<Settings>(context, listen: false);
settings.sshPublicKey = publicKey;
settings.sshPrivateKey = privateKey;
settings.sshPassword = password;
settings.save();
var gitConfig = Provider.of<GitConfig>(context, listen: false);
gitConfig.sshPublicKey = publicKey;
gitConfig.sshPrivateKey = privateKey;
gitConfig.sshPassword = password;
gitConfig.save();
setState(() {
this.publicKey = publicKey;
@ -323,11 +324,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
} else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) {
return GitHostUserProvidedKeysPage(
doneFunction: (publicKey, privateKey, password) async {
var settings = Provider.of<Settings>(context, listen: false);
settings.sshPublicKey = publicKey;
settings.sshPrivateKey = privateKey;
settings.sshPassword = password;
settings.save();
var gitConfig = Provider.of<GitConfig>(context, listen: false);
gitConfig.sshPublicKey = publicKey;
gitConfig.sshPrivateKey = privateKey;
gitConfig.sshPassword = password;
gitConfig.save();
setState(() {
this.publicKey = publicKey;
@ -478,11 +479,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
DateTime.now().toIso8601String().substring(0, 10); // only the date
generateSSHKeys(comment: comment).then((SshKey? sshKey) {
var settings = Provider.of<Settings>(context, listen: false);
settings.sshPublicKey = sshKey!.publicKey;
settings.sshPrivateKey = sshKey.privateKey;
settings.sshPassword = sshKey.password;
settings.save();
var gitConfig = Provider.of<GitConfig>(context, listen: false);
gitConfig.sshPublicKey = sshKey!.publicKey;
gitConfig.sshPrivateKey = sshKey.privateKey;
gitConfig.sshPassword = sshKey.password;
gitConfig.save();
setState(() {
publicKey = sshKey.publicKey;
@ -555,7 +556,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
var repo = context.read<GitJournalRepo>();
var basePath = repo.gitBaseDirectory;
var settings = Provider.of<Settings>(context, listen: false);
var gitConfig = Provider.of<GitConfig>(context, listen: false);
var repoPath = p.join(basePath, widget.repoFolderName);
Log.i("RepoPath: $repoPath");
@ -563,11 +564,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
cloneUrl: _gitCloneUrl,
remoteName: widget.remoteName,
repoPath: repoPath,
sshPassword: settings.sshPassword,
sshPrivateKey: settings.sshPrivateKey,
sshPublicKey: settings.sshPublicKey,
authorEmail: settings.gitAuthorEmail,
authorName: settings.gitAuthor,
sshPassword: gitConfig.sshPassword,
sshPrivateKey: gitConfig.sshPrivateKey,
sshPublicKey: gitConfig.sshPublicKey,
authorEmail: gitConfig.gitAuthorEmail,
authorName: gitConfig.gitAuthor,
progressUpdate: (GitTransferProgress p) {
setState(() {
_cloneProgress = p;
@ -593,6 +594,7 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
parameters: _buildOnboardingAnalytics(),
);
var settings = Provider.of<Settings>(context, listen: false);
var folderName = folderNameFromCloneUrl(_gitCloneUrl);
if (folderName != widget.repoFolderName) {
var newRepoPath = p.join(basePath, folderName);
@ -627,11 +629,11 @@ class GitHostSetupScreenState extends State<GitHostSetupScreen> {
// FIXME: Handle case when sshKey generation failed
return;
}
var settings = Provider.of<Settings>(context, listen: false);
settings.sshPublicKey = sshKey.publicKey;
settings.sshPrivateKey = sshKey.privateKey;
settings.sshPassword = sshKey.password;
settings.save();
var gitConfig = Provider.of<GitConfig>(context, listen: false);
gitConfig.sshPublicKey = sshKey.publicKey;
gitConfig.sshPrivateKey = sshKey.privateKey;
gitConfig.sshPassword = sshKey.password;
gitConfig.save();
setState(() {
publicKey = sshKey.publicKey;