Skip to content

Commit 9734026

Browse files
committed
refactor: remember last check state of Fetch all remotes and repect it while auto-fetching (#1647)
Signed-off-by: leo <[email protected]>
1 parent f85b4be commit 9734026

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

src/Models/RepositorySettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public bool EnableForceOnFetch
6262
set;
6363
} = false;
6464

65+
public bool FetchAllRemotes
66+
{
67+
get;
68+
set;
69+
} = false;
70+
6571
public bool FetchWithoutTags
6672
{
6773
get;

src/ViewModels/Fetch.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ public bool IsFetchAllRemoteVisible
1818

1919
public bool FetchAllRemotes
2020
{
21-
get;
22-
set;
23-
} = false;
21+
get => _fetchAllRemotes;
22+
set
23+
{
24+
if (SetProperty(ref _fetchAllRemotes, value) && IsFetchAllRemoteVisible)
25+
_repo.Settings.FetchAllRemotes = value;
26+
}
27+
}
2428

2529
public Models.Remote SelectedRemote
2630
{
@@ -44,6 +48,7 @@ public Fetch(Repository repo, Models.Remote preferredRemote = null)
4448
{
4549
_repo = repo;
4650
IsFetchAllRemoteVisible = repo.Remotes.Count > 1 && preferredRemote == null;
51+
_fetchAllRemotes = IsFetchAllRemoteVisible && _repo.Settings.FetchAllRemotes;
4752

4853
if (preferredRemote != null)
4954
{
@@ -98,5 +103,6 @@ public override async Task<bool> Sure()
98103
}
99104

100105
private readonly Repository _repo = null;
106+
private bool _fetchAllRemotes = false;
101107
}
102108
}

src/ViewModels/Repository.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1936,8 +1936,21 @@ private async void AutoFetchImpl(object sender)
19361936
}
19371937

19381938
Dispatcher.UIThread.Invoke(() => IsAutoFetching = true);
1939-
foreach (var remote in remotes)
1939+
1940+
if (_settings.FetchAllRemotes)
1941+
{
1942+
foreach (var remote in remotes)
1943+
await new Commands.Fetch(_fullpath, remote, false, false) { RaiseError = false }.RunAsync();
1944+
}
1945+
else if (remotes.Count > 0)
1946+
{
1947+
var remote = string.IsNullOrEmpty(_settings.DefaultRemote) ?
1948+
remotes.Find(x => x.Equals(_settings.DefaultRemote, StringComparison.Ordinal)) :
1949+
remotes[0];
1950+
19401951
await new Commands.Fetch(_fullpath, remote, false, false) { RaiseError = false }.RunAsync();
1952+
}
1953+
19411954
_lastFetchTime = DateTime.Now;
19421955
Dispatcher.UIThread.Invoke(() => IsAutoFetching = false);
19431956
}

0 commit comments

Comments
 (0)