-
Notifications
You must be signed in to change notification settings - Fork 386
Expand file tree
/
Copy pathPushTag.cs
More file actions
72 lines (62 loc) · 1.77 KB
/
PushTag.cs
File metadata and controls
72 lines (62 loc) · 1.77 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
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class PushTag : Popup
{
public Models.Tag Target
{
get;
}
public List<Models.Remote> Remotes
{
get => _repo.Remotes;
}
public Models.Remote SelectedRemote
{
get;
set;
}
public bool PushAllRemotes
{
get => _pushAllRemotes;
set => SetProperty(ref _pushAllRemotes, value);
}
public PushTag(Repository repo, Models.Tag target)
{
_repo = repo;
Target = target;
SelectedRemote = _repo.Remotes[0];
}
public override async Task<bool> Sure()
{
using var lockWatcher = _repo.LockWatcher();
ProgressDescription = "Pushing tag ...";
var log = _repo.CreateLog("Push Tag");
Use(log);
var succ = true;
var tag = $"refs/tags/{Target.Name}";
if (_pushAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
succ = await new Commands.Push(_repo.FullPath, remote.Name, tag, false)
.Use(log)
.RunAsync();
if (!succ)
break;
}
}
else
{
succ = await new Commands.Push(_repo.FullPath, SelectedRemote.Name, tag, false)
.Use(log)
.RunAsync();
}
log.Complete();
return succ;
}
private readonly Repository _repo = null;
private bool _pushAllRemotes = false;
}
}