diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 89cf0ddd..74a92064 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -121,6 +121,7 @@ Delete Branch Branch : You are about to delete a remote branch!!! + Also delete remote branch${0}$ Delete Remote Remote : Target : diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 9cbd77d4..8a9bd825 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -121,6 +121,7 @@ 删除分支确认 分支名 : 您正在删除远程上的分支,请务必小心!!! + 同时删除远程分支${0}$ 删除远程确认 远程名 : 目标 : diff --git a/src/ViewModels/DeleteBranch.cs b/src/ViewModels/DeleteBranch.cs index 5192383f..b5151e97 100644 --- a/src/ViewModels/DeleteBranch.cs +++ b/src/ViewModels/DeleteBranch.cs @@ -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; } } diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs index fe02ce23..a9f62516 100644 --- a/src/ViewModels/Histories.cs +++ b/src/ViewModels/Histories.cs @@ -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()) diff --git a/src/Views/DeleteBranch.axaml b/src/Views/DeleteBranch.axaml index 0427c271..8245c091 100644 --- a/src/Views/DeleteBranch.axaml +++ b/src/Views/DeleteBranch.axaml @@ -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}"/> - + @@ -20,12 +22,16 @@ - + + + + diff --git a/src/Views/Launcher.axaml.cs b/src/Views/Launcher.axaml.cs index c74d927a..c56de06b 100644 --- a/src/Views/Launcher.axaml.cs +++ b/src/Views/Launcher.axaml.cs @@ -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(); diff --git a/src/Views/NameHighlightedTextBlock.cs b/src/Views/NameHighlightedTextBlock.cs index 26ab9646..3be81186 100644 --- a/src/Views/NameHighlightedTextBlock.cs +++ b/src/Views/NameHighlightedTextBlock.cs @@ -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)