Repository navigation
Expand file tree
/
Copy pathDeleteBranch.cs
More file actions
80 lines (68 loc) · 2.36 KB
/
Copy pathDeleteBranch.cs
File metadata and controls
80 lines (68 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class DeleteBranch : Popup
{
public Models.Branch Target
{
get;
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))
{
TrackingRemoteBranch = repo.Branches.Find(x => x.FullName == branch.Upstream);
if (TrackingRemoteBranch != null)
DeleteTrackingRemoteTip = new Views.NameHighlightedTextBlock("DeleteBranch.WithTrackingRemote", TrackingRemoteBranch.FriendlyName);
}
View = new Views.DeleteBranch() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = "Deleting branch...";
return Task.Run(() =>
{
if (Target.IsLocal)
{
Commands.Branch.DeleteLocal(_repo.FullPath, Target.Name);
if (_alsoDeleteTrackingRemote && TrackingRemoteBranch != null)
{
SetProgressDescription("Deleting tracking remote branch...");
Commands.Branch.DeleteRemote(_repo.FullPath, TrackingRemoteBranch.Remote, TrackingRemoteBranch.Name);
}
}
else
{
Commands.Branch.DeleteRemote(_repo.FullPath, Target.Remote, Target.Name);
}
CallUIThread(() =>
{
_repo.MarkBranchesDirtyManually();
_repo.SetWatcherEnabled(true);
});
return true;
});
}
private readonly Repository _repo = null;
private bool _alsoDeleteTrackingRemote = false;
}
}