Skip to content

Commit ff32cf6

Browse files
committed
enhance: auto-fetching will respect git configuration (#1990)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 910431a commit ff32cf6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Commands/Fetch.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ public Fetch(string repo, string remote, bool noTags, bool force)
2222
Args = builder.ToString();
2323
}
2424

25+
public Fetch(string repo, string remote)
26+
{
27+
_remote = remote;
28+
29+
WorkingDirectory = repo;
30+
Context = repo;
31+
RaiseError = false;
32+
33+
Args = $"fetch --progress --verbose {remote}";
34+
}
35+
2536
public Fetch(string repo, Models.Branch local, Models.Branch remote)
2637
{
2738
_remote = remote.Remote;

src/ViewModels/Repository.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,8 @@ private void AutoFetchByTimer(object sender)
18251825

18261826
private async Task AutoFetchOnUIThread()
18271827
{
1828+
CommandLog log = null;
1829+
18281830
try
18291831
{
18301832
if (_settings is not { EnableAutoFetch: true })
@@ -1850,19 +1852,20 @@ private async Task AutoFetchOnUIThread()
18501852
remotes.Add(r.Name);
18511853

18521854
IsAutoFetching = true;
1855+
log = CreateLog("Auto-Fetch");
18531856

18541857
if (_settings.FetchAllRemotes)
18551858
{
18561859
foreach (var remote in remotes)
1857-
await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync();
1860+
await new Commands.Fetch(FullPath, remote).Use(log).RunAsync();
18581861
}
18591862
else if (remotes.Count > 0)
18601863
{
18611864
var remote = string.IsNullOrEmpty(_settings.DefaultRemote) ?
18621865
remotes.Find(x => x.Equals(_settings.DefaultRemote, StringComparison.Ordinal)) :
18631866
remotes[0];
18641867

1865-
await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync();
1868+
await new Commands.Fetch(FullPath, remote).Use(log).RunAsync();
18661869
}
18671870

18681871
_lastFetchTime = DateTime.Now;
@@ -1872,6 +1875,8 @@ private async Task AutoFetchOnUIThread()
18721875
{
18731876
// Ignore all exceptions.
18741877
}
1878+
1879+
log?.Complete();
18751880
}
18761881

18771882
private readonly bool _isWorktree = false;

0 commit comments

Comments
 (0)