diff --git a/src/Commands/Branch.cs b/src/Commands/Branch.cs
index 4ec8da82..ba35b326 100644
--- a/src/Commands/Branch.cs
+++ b/src/Commands/Branch.cs
@@ -34,12 +34,20 @@
return cmd.Exec();
}
- public static bool DeleteLocal(string repo, string name)
+ public static bool DeleteLocal(string repo, string name, bool deleteNotMerged)
{
var cmd = new Command();
cmd.WorkingDirectory = repo;
cmd.Context = repo;
- cmd.Args = $"branch -D {name}";
+ if (deleteNotMerged)
+ {
+ cmd.Args = $"branch -D {name}";
+ }
+ else
+ {
+ cmd.Args = $"branch -d {name}";
+ }
+
return cmd.Exec();
}
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index d06635eb..c91c790c 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -216,6 +216,7 @@
Branch:
You are about to delete a remote branch!!!
Also delete remote branch ${0}$
+ Also delete if not merged
Delete Multiple Branches
You are trying to delete multiple branches at one time. Be sure to double-check before taking action!
Delete Remote
diff --git a/src/ViewModels/DeleteBranch.cs b/src/ViewModels/DeleteBranch.cs
index e7136a0d..e9be3e3e 100644
--- a/src/ViewModels/DeleteBranch.cs
+++ b/src/ViewModels/DeleteBranch.cs
@@ -21,12 +21,24 @@ namespace SourceGit.ViewModels
get;
private set;
}
+
+ public object DeleteNotMergedTip
+ {
+ get;
+ private set;
+ }
public bool AlsoDeleteTrackingRemote
{
get => _alsoDeleteTrackingRemote;
set => SetProperty(ref _alsoDeleteTrackingRemote, value);
}
+
+ public bool DeleteNotMerged
+ {
+ get => _deleteNotMerged;
+ set => SetProperty(ref _deleteNotMerged, value);
+ }
public DeleteBranch(Repository repo, Models.Branch branch)
{
@@ -39,6 +51,7 @@ namespace SourceGit.ViewModels
if (TrackingRemoteBranch != null)
DeleteTrackingRemoteTip = new Views.NameHighlightedTextBlock("DeleteBranch.WithTrackingRemote", TrackingRemoteBranch.FriendlyName);
}
+ DeleteNotMergedTip = new Views.NameHighlightedTextBlock("DeleteBranch.NotMerged");
View = new Views.DeleteBranch() { DataContext = this };
}
@@ -52,7 +65,7 @@ namespace SourceGit.ViewModels
{
if (Target.IsLocal)
{
- Commands.Branch.DeleteLocal(_repo.FullPath, Target.Name);
+ Commands.Branch.DeleteLocal(_repo.FullPath, Target.Name, _deleteNotMerged);
if (_alsoDeleteTrackingRemote && TrackingRemoteBranch != null)
{
@@ -76,5 +89,6 @@ namespace SourceGit.ViewModels
private readonly Repository _repo = null;
private bool _alsoDeleteTrackingRemote = false;
+ private bool _deleteNotMerged = false;
}
}
diff --git a/src/ViewModels/DeleteMultipleBranches.cs b/src/ViewModels/DeleteMultipleBranches.cs
index 87bb3122..0202557e 100644
--- a/src/ViewModels/DeleteMultipleBranches.cs
+++ b/src/ViewModels/DeleteMultipleBranches.cs
@@ -10,11 +10,25 @@ namespace SourceGit.ViewModels
get;
}
- public DeleteMultipleBranches(Repository repo, List branches, bool isLocal)
+ public object DeleteNotMergedTip
+ {
+ get;
+ private set;
+ }
+
+ public bool DeleteNotMerged
+ {
+ get => _deleteNotMerged;
+ set => SetProperty(ref _deleteNotMerged, value);
+ }
+
+ public DeleteMultipleBranches(Repository repo, List branches, bool isLocal, bool deleteNotMerged)
{
_repo = repo;
_isLocal = isLocal;
+ _deleteNotMerged = deleteNotMerged;
Targets = branches;
+ DeleteNotMergedTip = new Views.NameHighlightedTextBlock("DeleteBranch.NotMerged");
View = new Views.DeleteMultipleBranches() { DataContext = this };
}
@@ -30,7 +44,7 @@ namespace SourceGit.ViewModels
foreach (var target in Targets)
{
SetProgressDescription($"Deleting local branch : {target.Name}");
- Commands.Branch.DeleteLocal(_repo.FullPath, target.Name);
+ Commands.Branch.DeleteLocal(_repo.FullPath, target.Name, _deleteNotMerged);
}
}
else
@@ -54,5 +68,6 @@ namespace SourceGit.ViewModels
private Repository _repo = null;
private bool _isLocal = false;
+ private bool _deleteNotMerged = false;
}
}
diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs
index 92bfb288..fd9d787b 100644
--- a/src/ViewModels/Repository.cs
+++ b/src/ViewModels/Repository.cs
@@ -944,10 +944,10 @@ namespace SourceGit.ViewModels
}
}
- public void DeleteMultipleBranches(List branches, bool isLocal)
+ public void DeleteMultipleBranches(List branches, bool isLocal, bool deleteNotMerged)
{
if (PopupHost.CanCreatePopup())
- PopupHost.ShowPopup(new DeleteMultipleBranches(this, branches, isLocal));
+ PopupHost.ShowPopup(new DeleteMultipleBranches(this, branches, isLocal, deleteNotMerged));
}
public void CreateNewTag()
diff --git a/src/Views/BranchTree.axaml.cs b/src/Views/BranchTree.axaml.cs
index 92c2b043..d8755f92 100644
--- a/src/Views/BranchTree.axaml.cs
+++ b/src/Views/BranchTree.axaml.cs
@@ -401,7 +401,7 @@ namespace SourceGit.Views
deleteMulti.Icon = App.CreateMenuIcon("Icons.Clear");
deleteMulti.Click += (_, ev) =>
{
- repo.DeleteMultipleBranches(branches, branches[0].IsLocal);
+ repo.DeleteMultipleBranches(branches, branches[0].IsLocal, false);
ev.Handled = true;
};
menu.Items.Add(deleteMulti);
diff --git a/src/Views/DeleteBranch.axaml b/src/Views/DeleteBranch.axaml
index b2693bf0..19b0b23c 100644
--- a/src/Views/DeleteBranch.axaml
+++ b/src/Views/DeleteBranch.axaml
@@ -11,7 +11,7 @@
Classes="bold"
Text="{DynamicResource Text.DeleteBranch}"/>
-
+
@@ -25,8 +25,12 @@
FontStyle="Italic"
VerticalAlignment="Center"/>
+
+
+
+
-
+
diff --git a/src/Views/DeleteMultipleBranches.axaml b/src/Views/DeleteMultipleBranches.axaml
index 2a888118..98c3a532 100644
--- a/src/Views/DeleteMultipleBranches.axaml
+++ b/src/Views/DeleteMultipleBranches.axaml
@@ -50,6 +50,10 @@
+
+
+
+