forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTag.cs
More file actions
59 lines (50 loc) · 1.63 KB
/
Copy pathTag.cs
File metadata and controls
59 lines (50 loc) · 1.63 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
using System.IO;
using System.Text;
using System.Threading.Tasks;
namespace SourceGit.Commands
{
public class Tag : Command
{
public Tag(string repo, string name)
{
WorkingDirectory = repo;
Context = repo;
_name = name;
}
public async Task<bool> AddAsync(string basedOn)
{
Args = $"tag --no-sign {_name} {basedOn}";
return await ExecAsync().ConfigureAwait(false);
}
public async Task<bool> AddAsync(string basedOn, string message, bool sign)
{
var builder = new StringBuilder();
builder
.Append("tag ")
.Append(sign ? "--sign -a " : "--no-sign -a ")
.Append(_name)
.Append(' ')
.Append(basedOn);
if (!string.IsNullOrEmpty(message))
{
string tmp = Path.GetTempFileName();
await File.WriteAllTextAsync(tmp, message);
builder.Append(" -F ").Append(tmp.Quoted());
Args = builder.ToString();
var succ = await ExecAsync().ConfigureAwait(false);
File.Delete(tmp);
return succ;
}
builder.Append(" -m ");
builder.Append(_name);
Args = builder.ToString();
return await ExecAsync().ConfigureAwait(false);
}
public async Task<bool> DeleteAsync()
{
Args = $"tag --delete {_name}";
return await ExecAsync().ConfigureAwait(false);
}
private readonly string _name;
}
}