Skip to content

Commit 0260672

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

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
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: 11 additions & 3 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 })
@@ -1849,20 +1851,24 @@ private async Task AutoFetchOnUIThread()
18491851
foreach (var r in _remotes)
18501852
remotes.Add(r.Name);
18511853

1854+
if (remotes.Count == 0)
1855+
return;
1856+
18521857
IsAutoFetching = true;
1858+
log = CreateLog("Auto-Fetch");
18531859

18541860
if (_settings.FetchAllRemotes)
18551861
{
18561862
foreach (var remote in remotes)
1857-
await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync();
1863+
await new Commands.Fetch(FullPath, remote).Use(log).RunAsync();
18581864
}
1859-
else if (remotes.Count > 0)
1865+
else
18601866
{
18611867
var remote = string.IsNullOrEmpty(_settings.DefaultRemote) ?
18621868
remotes.Find(x => x.Equals(_settings.DefaultRemote, StringComparison.Ordinal)) :
18631869
remotes[0];
18641870

1865-
await new Commands.Fetch(FullPath, remote, false, false) { RaiseError = false }.RunAsync();
1871+
await new Commands.Fetch(FullPath, remote).Use(log).RunAsync();
18661872
}
18671873

18681874
_lastFetchTime = DateTime.Now;
@@ -1872,6 +1878,8 @@ private async Task AutoFetchOnUIThread()
18721878
{
18731879
// Ignore all exceptions.
18741880
}
1881+
1882+
log?.Complete();
18751883
}
18761884

18771885
private readonly bool _isWorktree = false;

0 commit comments

Comments
 (0)