mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-28 15:45:00 +00:00
feature<Remote>: add 'Prune' context menu for remote to prune dead branches without fetching
This commit is contained in:
parent
0379d7e331
commit
9f58e0c715
6 changed files with 65 additions and 10 deletions
10
src/Views/Popups/Prune.xaml
Normal file
10
src/Views/Popups/Prune.xaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.Prune"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="500" Height="100">
|
||||
</controls:PopupWidget>
|
30
src/Views/Popups/Prune.xaml.cs
Normal file
30
src/Views/Popups/Prune.xaml.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 清理远程已删除分支
|
||||
/// </summary>
|
||||
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<bool> Start() {
|
||||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
var succ = new Commands.Remote(repo).Prune(remote);
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue