From e9bc7fc5be34fa950af42ac8529372e87d56e2f9 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 4 Aug 2025 18:22:25 +0800 Subject: [PATCH] refactor: disable `--all` by default while fetching (#1647) - If there's only one remote or we have selected the remote to fetch changes from, do not show `Fetch all remotes` option - Disable `--all` by default Signed-off-by: leo --- src/ViewModels/Fetch.cs | 15 ++++++++++----- src/Views/BranchTree.axaml.cs | 2 +- src/Views/Fetch.axaml | 13 ++++++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 0930e777..575e4b4b 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -10,11 +10,17 @@ namespace SourceGit.ViewModels get => _repo.Remotes; } + public bool IsFetchAllRemoteVisible + { + get; + private set; + } = true; + public bool FetchAllRemotes { - get => _fetchAllRemotes; - set => SetProperty(ref _fetchAllRemotes, value); - } + get; + set; + } = false; public Models.Remote SelectedRemote { @@ -37,7 +43,7 @@ namespace SourceGit.ViewModels public Fetch(Repository repo, Models.Remote preferredRemote = null) { _repo = repo; - _fetchAllRemotes = preferredRemote == null; + IsFetchAllRemoteVisible = repo.Remotes.Count > 1 && preferredRemote == null; if (preferredRemote != null) { @@ -92,6 +98,5 @@ namespace SourceGit.ViewModels } private readonly Repository _repo = null; - private bool _fetchAllRemotes; } } diff --git a/src/Views/BranchTree.axaml.cs b/src/Views/BranchTree.axaml.cs index fbf02da0..175c927b 100644 --- a/src/Views/BranchTree.axaml.cs +++ b/src/Views/BranchTree.axaml.cs @@ -894,7 +894,7 @@ namespace SourceGit.Views fetch.Click += (_, e) => { if (repo.CanCreatePopup()) - repo.ShowAndStartPopup(new ViewModels.Fetch(repo, remote)); + repo.ShowPopup(new ViewModels.Fetch(repo, remote)); e.Handled = true; }; diff --git a/src/Views/Fetch.axaml b/src/Views/Fetch.axaml index 67669380..c38fdb7e 100644 --- a/src/Views/Fetch.axaml +++ b/src/Views/Fetch.axaml @@ -11,7 +11,7 @@ - + + SelectedItem="{Binding SelectedRemote, Mode=TwoWay}"> + + + + + + @@ -38,8 +43,10 @@ ToolTip.Tip="--force"/>