mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
feature: allow deleting multiple branches at one time (#137)
This commit is contained in:
parent
99794e7ff7
commit
6fe96d629a
13 changed files with 492 additions and 87 deletions
53
src/ViewModels/DeleteMultipleBranches.cs
Normal file
53
src/ViewModels/DeleteMultipleBranches.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class DeleteMultipleBranches : Popup
|
||||
{
|
||||
public List<Models.Branch> Targets
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public DeleteMultipleBranches(Repository repo, List<Models.Branch> branches, bool isLocal)
|
||||
{
|
||||
_repo = repo;
|
||||
_isLocal = isLocal;
|
||||
Targets = branches;
|
||||
View = new Views.DeleteMultipleBranches() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Deleting multiple branches...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (_isLocal)
|
||||
{
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
SetProgressDescription($"Deleting local branch : {target.Name}");
|
||||
Commands.Branch.DeleteLocal(_repo.FullPath, target.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var target in Targets)
|
||||
{
|
||||
SetProgressDescription($"Deleting remote branch : {target.Remote}/{target.Name}");
|
||||
Commands.Branch.DeleteRemote(_repo.FullPath, target.Remote, target.Name);
|
||||
}
|
||||
}
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private Repository _repo = null;
|
||||
private bool _isLocal = false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue