-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy pathDeleteTag.cs
More file actions
54 lines (45 loc) · 1.46 KB
/
DeleteTag.cs
File metadata and controls
54 lines (45 loc) · 1.46 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
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class DeleteTag : Popup
{
public Models.Tag Target
{
get;
private set;
}
public bool PushToRemotes
{
get => _repo.UIStates.PushToRemoteWhenDeleteTag;
set => _repo.UIStates.PushToRemoteWhenDeleteTag = value;
}
public DeleteTag(Repository repo, Models.Tag tag)
{
_repo = repo;
Target = tag;
}
public override async Task<bool> Sure()
{
using var lockWatcher = _repo.LockWatcher();
ProgressDescription = $"Deleting tag '{Target.Name}' ...";
var remotes = PushToRemotes ? _repo.Remotes : [];
var log = _repo.CreateLog("Delete Tag");
Use(log);
var succ = await new Commands.Tag(_repo.FullPath, Target.Name)
.Use(log)
.DeleteAsync();
if (succ)
{
foreach (var r in remotes)
await new Commands.Push(_repo.FullPath, r.Name, $"refs/tags/{Target.Name}", true)
.Use(log)
.RunAsync();
}
log.Complete();
_repo.UIStates.RemoveHistoryFilter(Target.Name, Models.FilterType.Tag);
_repo.MarkTagsDirtyManually();
return succ;
}
private readonly Repository _repo = null;
}
}