mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature: add a checkbox to also delete the tracking remote branch (#99)
This commit is contained in:
parent
eced2e09bd
commit
d46979a0c5
7 changed files with 42 additions and 5 deletions
|
@ -121,6 +121,7 @@
|
|||
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">Delete Branch</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">Branch :</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">You are about to delete a remote branch!!!</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.WithTrackingRemote" xml:space="preserve">Also delete remote branch${0}$</x:String>
|
||||
<x:String x:Key="Text.DeleteRemote" xml:space="preserve">Delete Remote</x:String>
|
||||
<x:String x:Key="Text.DeleteRemote.Remote" xml:space="preserve">Remote :</x:String>
|
||||
<x:String x:Key="Text.DeleteRepositoryNode.Target" xml:space="preserve">Target :</x:String>
|
||||
|
|
|
@ -121,6 +121,7 @@
|
|||
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">删除分支确认</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">分支名 :</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">您正在删除远程上的分支,请务必小心!!!</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.WithTrackingRemote" xml:space="preserve">同时删除远程分支${0}$</x:String>
|
||||
<x:String x:Key="Text.DeleteRemote" xml:space="preserve">删除远程确认</x:String>
|
||||
<x:String x:Key="Text.DeleteRemote.Remote" xml:space="preserve">远程名 :</x:String>
|
||||
<x:String x:Key="Text.DeleteRepositoryNode.Target" xml:space="preserve">目标 :</x:String>
|
||||
|
|
|
@ -10,10 +10,36 @@ namespace SourceGit.ViewModels
|
|||
private set;
|
||||
}
|
||||
|
||||
public Models.Branch TrackingRemoteBranch
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public object DeleteTrackingRemoteTip
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool AlsoDeleteTrackingRemote
|
||||
{
|
||||
get => _alsoDeleteTrackingRemote;
|
||||
set => SetProperty(ref _alsoDeleteTrackingRemote, value);
|
||||
}
|
||||
|
||||
public DeleteBranch(Repository repo, Models.Branch branch)
|
||||
{
|
||||
_repo = repo;
|
||||
Target = branch;
|
||||
|
||||
if (branch.IsLocal && !string.IsNullOrEmpty(branch.Upstream))
|
||||
{
|
||||
var upstream = branch.Upstream.Substring(13);
|
||||
TrackingRemoteBranch = repo.Branches.Find(x => !x.IsLocal && $"{x.Remote}/{x.Name}" == upstream);
|
||||
DeleteTrackingRemoteTip = new Views.NameHighlightedTextBlock("DeleteBranch.WithTrackingRemote", upstream);
|
||||
}
|
||||
|
||||
View = new Views.DeleteBranch() { DataContext = this };
|
||||
}
|
||||
|
||||
|
@ -27,6 +53,9 @@ namespace SourceGit.ViewModels
|
|||
if (Target.IsLocal)
|
||||
{
|
||||
Commands.Branch.Delete(_repo.FullPath, Target.Name);
|
||||
|
||||
if (_alsoDeleteTrackingRemote && TrackingRemoteBranch != null)
|
||||
new Commands.Push(_repo.FullPath, TrackingRemoteBranch.Remote, TrackingRemoteBranch.Name).Exec();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -39,5 +68,6 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
private bool _alsoDeleteTrackingRemote = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,7 +383,6 @@ namespace SourceGit.ViewModels
|
|||
fastForward.Header = new Views.NameHighlightedTextBlock("BranchCM.FastForward", upstream);
|
||||
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
|
||||
fastForward.IsEnabled = !string.IsNullOrEmpty(current.UpstreamTrackStatus) && current.UpstreamTrackStatus.IndexOf('↑') < 0;
|
||||
;
|
||||
fastForward.Click += (o, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:m="using:SourceGit.Models"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.DeleteBranch"
|
||||
|
@ -12,7 +14,7 @@
|
|||
Classes="bold"
|
||||
Text="{DynamicResource Text.DeleteBranch}"/>
|
||||
|
||||
<Grid Margin="0,16,8,0" RowDefinitions="32,Auto" ColumnDefinitions="150,*">
|
||||
<Grid Margin="0,16,8,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Text="{DynamicResource Text.DeleteBranch.Branch}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14" Margin="8,0" Data="{StaticResource Icons.Branch}"/>
|
||||
|
@ -20,12 +22,16 @@
|
|||
</StackPanel>
|
||||
|
||||
<Border Grid.Row="1" Grid.Column="1" Height="32" IsVisible="{Binding !Target.IsLocal}">
|
||||
<TextBlock Margin="8,0"
|
||||
<TextBlock Margin="6,0,0,0"
|
||||
Text="{DynamicResource Text.DeleteBranch.IsRemoteTip}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontStyle="Italic"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Grid.Column="1" Height="32" IsVisible="{Binding TrackingRemoteBranch, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<CheckBox Margin="6,0,0,0" Content="{Binding DeleteTrackingRemoteTip}" IsChecked="{Binding AlsoDeleteTrackingRemote, Mode=TwoWay}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
else if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Right) ||
|
||||
else if ((OperatingSystem.IsMacOS() && e.KeyModifiers.HasFlag(KeyModifiers.Alt) && e.Key == Key.Right) ||
|
||||
(!OperatingSystem.IsMacOS() && e.Key == Key.Tab))
|
||||
{
|
||||
vm.GotoNextTab();
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace SourceGit.Views
|
|||
FontSize,
|
||||
Foreground);
|
||||
|
||||
return new Size(formatted.Width - 16, formatted.Height);
|
||||
return new Size(formatted.Width, formatted.Height);
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
|
|
Loading…
Reference in a new issue