mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 19:02:39 +08:00
- Remove all synchronous method in commands - `Command.ReadToEndAsync` now is protected method - Rename `ResultAsync` to `GetResultAsync` - Call `ConfigureAwait(false)` when there's no context Signed-off-by: leo <longshuang@msn.cn>
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public partial class QueryAssumeUnchangedFiles : Command
|
|
{
|
|
[GeneratedRegex(@"^(\w)\s+(.+)$")]
|
|
private static partial Regex REG_PARSE();
|
|
|
|
public QueryAssumeUnchangedFiles(string repo)
|
|
{
|
|
WorkingDirectory = repo;
|
|
Args = "ls-files -v";
|
|
RaiseError = false;
|
|
}
|
|
|
|
public async Task<List<string>> GetResultAsync()
|
|
{
|
|
var outs = new List<string>();
|
|
var rs = await ReadToEndAsync().ConfigureAwait(false);
|
|
var lines = rs.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
|
|
foreach (var line in lines)
|
|
{
|
|
var match = REG_PARSE().Match(line);
|
|
if (!match.Success)
|
|
continue;
|
|
|
|
if (match.Groups[1].Value == "h")
|
|
outs.Add(match.Groups[2].Value);
|
|
}
|
|
|
|
return outs;
|
|
}
|
|
}
|
|
}
|