From b2e08550bb1d01c098951d611c76aeb1b21f04c7 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 26 Jul 2021 20:17:45 +0200 Subject: [PATCH] Add GitConfig This makes the Settings class smaller. --- lib/app.dart | 18 +++++---- lib/core/git_repo.dart | 50 ++++++++++++------------- lib/repository.dart | 21 +++++++---- lib/settings/git_config.dart | 50 +++++++++++++++++++++++++ lib/settings/settings.dart | 26 ------------- lib/settings/settings_git_remote.dart | 21 ++++++----- lib/settings/settings_screen.dart | 16 ++++---- lib/setup/autoconfigure.dart | 10 ++--- lib/setup/screens.dart | 54 ++++++++++++++------------- 9 files changed, 153 insertions(+), 113 deletions(-) create mode 100644 lib/settings/git_config.dart diff --git a/lib/app.dart b/lib/app.dart index c620e6d0..ff42d57a 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -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( - builder: (_, repo, __) => ChangeNotifierProvider.value( - value: repo.settings, - child: Consumer( - builder: (_, repo, __) => - ChangeNotifierProvider.value( - value: repo.notesFolder, - child: child, + builder: (_, repo, __) => ChangeNotifierProvider.value( + value: repo.gitConfig, + child: ChangeNotifierProvider.value( + value: repo.settings, + child: Consumer( + builder: (_, repo, __) => + ChangeNotifierProvider.value( + value: repo.notesFolder, + child: child, + ), ), ), ), diff --git a/lib/core/git_repo.dart b/lib/core/git_repo.dart index fcbc851e..4d6ab78b 100644 --- a/lib/core/git_repo.dart +++ b/lib/core/git_repo.dart @@ -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(); diff --git a/lib/repository.dart b/lib/repository.dart index 0fa8d82e..873e3696 100644 --- a/lib/repository.dart +++ b/lib/repository.dart @@ -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 _copyDirectory(String source, String destination) async { /// one commit. It makes doing a git pull and push easier Future _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 _addFileInRepo({ await repo.commit( message: "Add gitignore file", - authorEmail: settings.gitAuthorEmail, - authorName: settings.gitAuthor, + authorEmail: config.gitAuthorEmail, + authorName: config.gitAuthor, ); } } diff --git a/lib/settings/git_config.dart b/lib/settings/git_config.dart new file mode 100644 index 00000000..f0e9afbd --- /dev/null +++ b/lib/settings/git_config.dart @@ -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 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 toLoggableMap() { + return { + "gitAuthor": gitAuthor.isNotEmpty.toString(), + "gitAuthorEmail": gitAuthorEmail.isNotEmpty.toString(), + 'sshPublicKey': sshPublicKey.isNotEmpty.toString(), + 'sshPrivateKey': sshPrivateKey.isNotEmpty.toString(), + 'sshPassword': sshPassword.isNotEmpty.toString(), + }; + } +} diff --git a/lib/settings/settings.dart b/lib/settings/settings.dart index 726e5752..98fb8529 100644 --- a/lib/settings/settings.dart +++ b/lib/settings/settings.dart @@ -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 toLoggableMap() { return { - "gitAuthor": gitAuthor.isNotEmpty.toString(), - "gitAuthorEmail": gitAuthorEmail.isNotEmpty.toString(), - 'sshPublicKey': sshPublicKey.isNotEmpty.toString(), - 'sshPrivateKey': sshPrivateKey.isNotEmpty.toString(), "noteFileNameFormat": noteFileNameFormat.toInternalString(), "journalNoteFileNameFormat": journalNoteFileNameFormat.toInternalString(), "yamlModifiedKey": yamlModifiedKey, diff --git a/lib/settings/settings_git_remote.dart b/lib/settings/settings_git_remote.dart index 18342e90..238e6774 100644 --- a/lib/settings/settings_git_remote.dart +++ b/lib/settings/settings_git_remote.dart @@ -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 { } void _updateKeys(String publicKey, String privateKey, String password) { - var settings = Provider.of(context, listen: false); + var config = Provider.of(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 { DateTime.now().toIso8601String().substring(0, 10); // only the date generateSSHKeys(comment: comment).then((SshKey? sshKey) { - var settings = Provider.of(context, listen: false); - settings.sshPublicKey = sshKey!.publicKey; - settings.sshPrivateKey = sshKey.publicKey; - settings.sshPassword = sshKey.password; - settings.save(); + var config = Provider.of(context, listen: false); + config.sshPublicKey = sshKey!.publicKey; + config.sshPrivateKey = sshKey.publicKey; + config.sshPassword = sshKey.password; + config.save(); Log.d("PublicKey: " + sshKey.publicKey); _copyKeyToClipboard(context); diff --git a/lib/settings/settings_screen.dart b/lib/settings/settings_screen.dart index 49d065b8..dcdffc59 100644 --- a/lib/settings/settings_screen.dart +++ b/lib/settings/settings_screen.dart @@ -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 { @override Widget build(BuildContext context) { var settings = Provider.of(context); + var gitConfig = Provider.of(context); var appSettings = Provider.of(context); final repo = Provider.of(context); var repoManager = Provider.of(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 { 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 { 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 { 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 { onTap: () { var route = MaterialPageRoute( builder: (context) => - GitRemoteSettingsScreen(settings.sshPublicKey), + GitRemoteSettingsScreen(gitConfig.sshPublicKey), settings: const RouteSettings(name: '/settings/gitRemote'), ); Navigator.of(context).push(route); diff --git a/lib/setup/autoconfigure.dart b/lib/setup/autoconfigure.dart index a942428d..d13796c7 100644 --- a/lib/setup/autoconfigure.dart +++ b/lib/setup/autoconfigure.dart @@ -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(context, listen: false); + var gitConfig = Provider.of(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; diff --git a/lib/setup/screens.dart b/lib/setup/screens.dart index 895b769a..ff402d45 100644 --- a/lib/setup/screens.dart +++ b/lib/setup/screens.dart @@ -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 { return GitHostUserProvidedKeysPage( doneFunction: (String publicKey, String privateKey, String password) async { - var settings = Provider.of(context, listen: false); - settings.sshPublicKey = publicKey; - settings.sshPrivateKey = privateKey; - settings.sshPassword = password; - settings.save(); + var gitConfig = Provider.of(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 { } else if (_keyGenerationChoice == KeyGenerationChoice.UserProvided) { return GitHostUserProvidedKeysPage( doneFunction: (publicKey, privateKey, password) async { - var settings = Provider.of(context, listen: false); - settings.sshPublicKey = publicKey; - settings.sshPrivateKey = privateKey; - settings.sshPassword = password; - settings.save(); + var gitConfig = Provider.of(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 { DateTime.now().toIso8601String().substring(0, 10); // only the date generateSSHKeys(comment: comment).then((SshKey? sshKey) { - var settings = Provider.of(context, listen: false); - settings.sshPublicKey = sshKey!.publicKey; - settings.sshPrivateKey = sshKey.privateKey; - settings.sshPassword = sshKey.password; - settings.save(); + var gitConfig = Provider.of(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 { var repo = context.read(); var basePath = repo.gitBaseDirectory; - var settings = Provider.of(context, listen: false); + var gitConfig = Provider.of(context, listen: false); var repoPath = p.join(basePath, widget.repoFolderName); Log.i("RepoPath: $repoPath"); @@ -563,11 +564,11 @@ class GitHostSetupScreenState extends State { 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 { parameters: _buildOnboardingAnalytics(), ); + var settings = Provider.of(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 { // FIXME: Handle case when sshKey generation failed return; } - var settings = Provider.of(context, listen: false); - settings.sshPublicKey = sshKey.publicKey; - settings.sshPrivateKey = sshKey.privateKey; - settings.sshPassword = sshKey.password; - settings.save(); + var gitConfig = Provider.of(context, listen: false); + gitConfig.sshPublicKey = sshKey.publicKey; + gitConfig.sshPrivateKey = sshKey.privateKey; + gitConfig.sshPassword = sshKey.password; + gitConfig.save(); setState(() { publicKey = sshKey.publicKey;