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>
28 lines
713 B
C#
28 lines
713 B
C#
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class QueryGitDir : Command
|
|
{
|
|
public QueryGitDir(string workDir)
|
|
{
|
|
WorkingDirectory = workDir;
|
|
Args = "rev-parse --git-dir";
|
|
}
|
|
|
|
public async Task<string> GetResultAsync()
|
|
{
|
|
var rs = await ReadToEndAsync().ConfigureAwait(false);
|
|
if (!rs.IsSuccess)
|
|
return null;
|
|
|
|
var stdout = rs.StdOut.Trim();
|
|
if (string.IsNullOrEmpty(stdout))
|
|
return null;
|
|
|
|
return Path.IsPathRooted(stdout) ? stdout : Path.GetFullPath(Path.Combine(WorkingDirectory, stdout));
|
|
}
|
|
}
|
|
}
|