diff --git a/src/Commands/Remote.cs b/src/Commands/Remote.cs index 7bbc73ad..09326afd 100644 --- a/src/Commands/Remote.cs +++ b/src/Commands/Remote.cs @@ -23,6 +23,11 @@ namespace SourceGit.Commands { return Exec(); } + public bool Prune(string name) { + Args = $"remote prune {name}"; + return Exec(); + } + public bool SetURL(string name, string url) { Args = $"remote set-url {name} {url}"; return Exec(); diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index ed9d45df..e6580b6c 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -185,10 +185,11 @@ Copy Branch Name Unset Upstream - Fetch '{0}' - Edit '{0}' - Delete '{0}' - Copy Remote URL + Fetch ... + Prune + Edit ... + Delete ... + Copy URL Reset '{0}' to Here Rebase '{0}' to Here diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index b28eb483..ad67a4b2 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -184,9 +184,10 @@ 复制分支名 取消追踪 - 拉取 '{0}' 更新 - 编辑 '{0}' - 删除 '{0}' + 拉取更新 ... + 清理远程已删除分支 + 编辑 ... + 删除 ... 复制远程地址 重置 '{0}' 到此处 diff --git a/src/Views/Popups/Prune.xaml b/src/Views/Popups/Prune.xaml new file mode 100644 index 00000000..2a207bd7 --- /dev/null +++ b/src/Views/Popups/Prune.xaml @@ -0,0 +1,10 @@ + + diff --git a/src/Views/Popups/Prune.xaml.cs b/src/Views/Popups/Prune.xaml.cs new file mode 100644 index 00000000..cca1e137 --- /dev/null +++ b/src/Views/Popups/Prune.xaml.cs @@ -0,0 +1,30 @@ +using System.Threading.Tasks; + +namespace SourceGit.Views.Popups { + /// + /// 清理远程已删除分支 + /// + public partial class Prune : Controls.PopupWidget { + private string repo = null; + private string remote = null; + + public Prune(string repo, string remote) { + this.repo = repo; + this.remote = remote; + InitializeComponent(); + } + + public override string GetTitle() { + return App.Text("RemoteCM.Prune"); + } + + public override Task Start() { + return Task.Run(() => { + Models.Watcher.SetEnabled(repo, false); + var succ = new Commands.Remote(repo).Prune(remote); + Models.Watcher.SetEnabled(repo, true); + return succ; + }); + } + } +} diff --git a/src/Views/Widgets/Dashboard.xaml.cs b/src/Views/Widgets/Dashboard.xaml.cs index 1573e494..5354bc5e 100644 --- a/src/Views/Widgets/Dashboard.xaml.cs +++ b/src/Views/Widgets/Dashboard.xaml.cs @@ -745,21 +745,28 @@ namespace SourceGit.Views.Widgets { private void FillRemoteContextMenu(ContextMenu menu, Models.Remote remote) { var fetch = new MenuItem(); - fetch.Header = App.Text("RemoteCM.Fetch", remote.Name); + fetch.Header = App.Text("RemoteCM.Fetch"); fetch.Click += (o, e) => { new Popups.Fetch(repo, remote.Name).Show(); e.Handled = true; }; + var prune = new MenuItem(); + prune.Header = App.Text("RemoteCM.Prune"); + prune.Click += (o, e) => { + new Popups.Prune(repo.Path, remote.Name).ShowAndStart(); + e.Handled = true; + }; + var edit = new MenuItem(); - edit.Header = App.Text("RemoteCM.Edit", remote.Name); + edit.Header = App.Text("RemoteCM.Edit"); edit.Click += (o, e) => { new Popups.Remote(repo, remote).Show(); e.Handled = true; }; var delete = new MenuItem(); - delete.Header = App.Text("RemoteCM.Delete", remote.Name); + delete.Header = App.Text("RemoteCM.Delete"); delete.Click += (o, e) => { new Popups.DeleteRemote(repo.Path, remote.Name).Show(); e.Handled = true; @@ -773,6 +780,7 @@ namespace SourceGit.Views.Widgets { }; menu.Items.Add(fetch); + menu.Items.Add(prune); menu.Items.Add(new Separator()); menu.Items.Add(edit); menu.Items.Add(delete);