-
Notifications
You must be signed in to change notification settings - Fork 510
Expand file tree
/
Copy pathMergeBase.cs
More file actions
32 lines (27 loc) · 848 Bytes
/
Copy pathMergeBase.cs
File metadata and controls
32 lines (27 loc) · 848 Bytes
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
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace SourceGit.Commands
{
public partial class MergeBase : Command
{
[GeneratedRegex(@"^[0-9a-f]{8,64}$")]
private static partial Regex REG_HEX();
public MergeBase(string repo, string rev1, string rev2)
{
WorkingDirectory = repo;
Context = repo;
RaiseError = false;
Args = $"merge-base {rev1} {rev2}";
}
public async Task<string> GetResultAsync()
{
var rs = await ReadToEndAsync().ConfigureAwait(false);
if (!rs.IsSuccess)
return string.Empty;
var trimmed = rs.StdOut.Trim();
if (REG_HEX().IsMatch(trimmed))
return trimmed;
return string.Empty;
}
}
}