feature: add an option in repository configuration to enable --prune on fetch (#590)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-30 18:39:38 +08:00
parent a4befd010a
commit 3cbffa6ff9
No known key found for this signature in database
12 changed files with 50 additions and 11 deletions

View file

@ -100,7 +100,7 @@ namespace SourceGit.ViewModels
{
SetProgressDescription("Fetching from added remote ...");
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
new Commands.Fetch(_repo.FullPath, _name, false, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, _name, false, false, SetProgressDescription).Exec();
}
CallUIThread(() =>
{

View file

@ -40,6 +40,8 @@ namespace SourceGit.ViewModels
{
_repo.SetWatcherEnabled(false);
var notags = _repo.Settings.FetchWithoutTags;
var prune = _repo.Settings.EnablePruneOnFetch;
return Task.Run(() =>
{
if (FetchAllRemotes)
@ -47,13 +49,13 @@ namespace SourceGit.ViewModels
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Fetching remote: {remote.Name}");
new Commands.Fetch(_repo.FullPath, remote.Name, NoTags, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, SetProgressDescription).Exec();
}
}
else
{
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, NoTags, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, SetProgressDescription).Exec();
}
CallUIThread(() =>

View file

@ -147,7 +147,13 @@ namespace SourceGit.ViewModels
if (FetchAllBranches)
{
SetProgressDescription($"Fetching remote: {_selectedRemote.Name}...");
rs = new Commands.Fetch(_repo.FullPath, _selectedRemote.Name, NoTags, SetProgressDescription).Exec();
rs = new Commands.Fetch(
_repo.FullPath,
_selectedRemote.Name,
NoTags,
_repo.Settings.EnablePruneOnFetch,
SetProgressDescription).Exec();
if (!rs)
{
CallUIThread(() => _repo.SetWatcherEnabled(true));
@ -171,7 +177,14 @@ namespace SourceGit.ViewModels
else
{
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, NoTags, SetProgressDescription).Exec();
rs = new Commands.Pull(
_repo.FullPath,
_selectedRemote.Name,
_selectedBranch.Name,
UseRebase,
NoTags,
_repo.Settings.EnablePruneOnFetch,
SetProgressDescription).Exec();
}
if (rs && needPopStash)

View file

@ -2137,7 +2137,7 @@ namespace SourceGit.ViewModels
IsAutoFetching = true;
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
new Commands.Fetch(_fullpath, "--all", false, null) { RaiseError = false }.Exec();
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, null) { RaiseError = false }.Exec();
_lastFetchTime = DateTime.Now;
IsAutoFetching = false;
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));

View file

@ -67,6 +67,12 @@ namespace SourceGit.ViewModels
set => _repo.Settings.EnableSignOffForCommit = value;
}
public bool EnablePruneOnFetch
{
get => _repo.Settings.EnablePruneOnFetch;
set => _repo.Settings.EnablePruneOnFetch = value;
}
public bool EnableAutoFetch
{
get => _repo.Settings.EnableAutoFetch;
@ -134,7 +140,7 @@ namespace SourceGit.ViewModels
AvailableOpenAIServices.Add(service.Name);
if (AvailableOpenAIServices.IndexOf(PreferedOpenAIService) == -1)
PreferedOpenAIService = "---";
PreferedOpenAIService = "---";
_cached = new Commands.Config(repo.FullPath).ListAll();
if (_cached.TryGetValue("user.name", out var name))