diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs index 834cd7fc..1c3e78cb 100644 --- a/src/Commands/Fetch.cs +++ b/src/Commands/Fetch.cs @@ -4,7 +4,7 @@ namespace SourceGit.Commands { public class Fetch : Command { - public Fetch(string repo, string remote, bool noTags, bool prune, Action outputHandler) + public Fetch(string repo, string remote, bool noTags, bool prune, bool force, Action outputHandler) { _outputHandler = outputHandler; WorkingDirectory = repo; @@ -18,6 +18,9 @@ namespace SourceGit.Commands else Args += "--tags "; + if (force) + Args += "--force "; + if (prune) Args += "--prune "; diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 799288ef..0a0af997 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -268,6 +268,7 @@ Fast-Forward (without checkout) Fetch Fetch all remotes + Enable '--force' option Fetch without tags Remote: Fetch Remote Changes diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 21837119..1b549c83 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -271,6 +271,7 @@ 快进(fast-forward,无需checkout) 拉取(fetch) 拉取所有的远程仓库 + 启用 --force 选项 不拉取远程标签 远程仓库 : 拉取远程仓库内容 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 59b0afe0..f4ec03ad 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -271,6 +271,7 @@ 快進 (fast-forward,無需 checkout) 提取 (fetch) 提取所有的遠端存放庫 + 啟用 [--force] 選項 不提取遠端標籤 遠端存放庫: 提取遠端存放庫內容 diff --git a/src/ViewModels/AddRemote.cs b/src/ViewModels/AddRemote.cs index d6424572..2ca7449f 100644 --- a/src/ViewModels/AddRemote.cs +++ b/src/ViewModels/AddRemote.cs @@ -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, false, SetProgressDescription).Exec(); + new Commands.Fetch(_repo.FullPath, _name, false, false, false, SetProgressDescription).Exec(); } CallUIThread(() => { diff --git a/src/ViewModels/Fetch.cs b/src/ViewModels/Fetch.cs index 7f54680d..a93304f7 100644 --- a/src/ViewModels/Fetch.cs +++ b/src/ViewModels/Fetch.cs @@ -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(() => diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 6c493449..e7c62980 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -152,6 +152,7 @@ namespace SourceGit.ViewModels _selectedRemote.Name, NoTags, _repo.Settings.EnablePruneOnFetch, + false, SetProgressDescription).Exec(); if (!rs) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 3182ab6f..a5d48648 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -2194,7 +2194,7 @@ namespace SourceGit.ViewModels IsAutoFetching = true; Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching))); - new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, null) { RaiseError = false }.Exec(); + new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, false, null) { RaiseError = false }.Exec(); _lastFetchTime = DateTime.Now; IsAutoFetching = false; Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching))); diff --git a/src/Views/Fetch.axaml b/src/Views/Fetch.axaml index a9c2fd90..f9380ab0 100644 --- a/src/Views/Fetch.axaml +++ b/src/Views/Fetch.axaml @@ -11,7 +11,7 @@ - + + + -