diff --git a/assets/langs/en.yaml b/assets/langs/en.yaml index 2277a6c3..65372676 100644 --- a/assets/langs/en.yaml +++ b/assets/langs/en.yaml @@ -45,6 +45,7 @@ settings: cancel: Cancel title: Git Remote Settings subtitle: Configure where your notes are synced + host: Git Host noteMetaData: title: Note Metadata Settings subtitle: Configure how the Note Metadata is saved diff --git a/changelog.yml b/changelog.yml index 5eed8e48..05529a0d 100644 --- a/changelog.yml +++ b/changelog.yml @@ -11,6 +11,7 @@ - text: "Custom SSH keys with passwords can now be used - #227" - text: "Create new note when clicking on non existing Wiki Link - #240" - text: "Debug Screen: Add a button to easily copy all the logs" + - text: "Git Remote Settings: Expose the git host" bugs: - text: "Fix notes not always showing up - #270" diff --git a/lib/repository.dart b/lib/repository.dart index 642ba940..2bc8c261 100644 --- a/lib/repository.dart +++ b/lib/repository.dart @@ -517,6 +517,11 @@ class Repository with ChangeNotifier { await repo.checkout(note.filePath); return note.load(); } + + Future> remoteConfigs() async { + var repo = await GitRepository.load(repoPath); + return repo.config.remotes; + } } Future _copyDirectory(String source, String destination) async { diff --git a/lib/screens/settings_git_remote.dart b/lib/screens/settings_git_remote.dart index a61f5ab5..52b82880 100644 --- a/lib/screens/settings_git_remote.dart +++ b/lib/screens/settings_git_remote.dart @@ -28,13 +28,35 @@ class GitRemoteSettingsScreen extends StatefulWidget { } class _GitRemoteSettingsScreenState extends State { + String remoteHost; + @override Widget build(BuildContext context) { var textTheme = Theme.of(context).textTheme; var settings = Provider.of(context); + var repo = Provider.of(context); + + if (remoteHost == null) { + remoteHost = ""; + repo.remoteConfigs().then((list) { + setState(() { + if (!mounted) return; + remoteHost = list.first.url; + }); + }); + } var body = Column( children: [ + if (remoteHost != null && remoteHost.isNotEmpty) + Text( + tr('settings.gitRemote.host'), + style: textTheme.bodyText1, + textAlign: TextAlign.left, + ), + if (remoteHost != null && remoteHost.isNotEmpty) + ListTile(title: Text(remoteHost)), + const SizedBox(height: 16.0), Text( tr('setup.sshKeyUserProvided.public'), style: textTheme.bodyText1,