From 084c8a8bc7d54beac76057b43a3b74d807a3bcbb Mon Sep 17 00:00:00 2001 From: Thomas Michiels Date: Thu, 18 Dec 2025 15:28:31 +0100 Subject: [PATCH] add background fetch to log + background fetch respects git defaults (since you have no explicit option to use) ammend: fix formatting --- src/Commands/Fetch.cs | 5 +++-- src/ViewModels/Repository.cs | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs index 9a599f821..8a0001694 100644 --- a/src/Commands/Fetch.cs +++ b/src/Commands/Fetch.cs @@ -5,7 +5,7 @@ namespace SourceGit.Commands { public class Fetch : Command { - public Fetch(string repo, string remote, bool noTags, bool force) + public Fetch(string repo, string remote, bool? noTags, bool force) { _remote = remote; @@ -14,7 +14,8 @@ public Fetch(string repo, string remote, bool noTags, bool force) var builder = new StringBuilder(512); builder.Append("fetch --progress --verbose "); - builder.Append(noTags ? "--no-tags " : "--tags "); + if (noTags.HasValue) + builder.Append(noTags.Value ? "--no-tags " : "--tags "); if (force) builder.Append("--force "); builder.Append(remote); diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index e90ad246c..10a923869 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1850,11 +1850,14 @@ private async Task AutoFetchOnUIThread() remotes.Add(r.Name); IsAutoFetching = true; + var log = CreateLog("background Fetch"); if (_settings.FetchAllRemotes) { foreach (var remote in remotes) - await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync(); + await new Commands.Fetch(FullPath, remote, null, false) { RaiseError = false } + .Use(log) + .RunAsync(); } else if (remotes.Count > 0) { @@ -1862,9 +1865,13 @@ private async Task AutoFetchOnUIThread() remotes.Find(x => x.Equals(_settings.DefaultRemote, StringComparison.Ordinal)) : remotes[0]; - await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync(); + await new Commands.Fetch(FullPath, remote, null, false) { RaiseError = false } + .Use(log) + .RunAsync(); } + log.Complete(); + _lastFetchTime = DateTime.Now; IsAutoFetching = false; }