feature: supports toggle --force option for git fetch command (#721)

* Background auto fetch will always disable this option
* This option is not add to pull operation

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-11-22 09:39:50 +08:00
parent c1c743f2ff
commit 153a1f30b2
No known key found for this signature in database
9 changed files with 26 additions and 7 deletions

View file

@ -28,10 +28,17 @@ namespace SourceGit.ViewModels
set => _repo.Settings.FetchWithoutTags = value;
}
public bool Force
{
get;
set;
}
public Fetch(Repository repo, Models.Remote preferedRemote = null)
{
_repo = repo;
_fetchAllRemotes = preferedRemote == null;
Force = false;
SelectedRemote = preferedRemote != null ? preferedRemote : _repo.Remotes[0];
View = new Views.Fetch() { DataContext = this };
}
@ -42,6 +49,7 @@ namespace SourceGit.ViewModels
var notags = _repo.Settings.FetchWithoutTags;
var prune = _repo.Settings.EnablePruneOnFetch;
var force = Force;
return Task.Run(() =>
{
if (FetchAllRemotes)
@ -49,13 +57,13 @@ namespace SourceGit.ViewModels
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Fetching remote: {remote.Name}");
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, force, SetProgressDescription).Exec();
}
}
else
{
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, force, SetProgressDescription).Exec();
}
CallUIThread(() =>