mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-24 10:50:52 +08:00
31 lines
699 B
C#
31 lines
699 B
C#
using System.IO;
|
|
|
|
namespace SourceGit.Commands
|
|
{
|
|
public class QueryGitDir : Command
|
|
{
|
|
public QueryGitDir(string workDir)
|
|
{
|
|
WorkingDirectory = workDir;
|
|
Args = "rev-parse --git-dir";
|
|
}
|
|
|
|
public string GetResult()
|
|
{
|
|
return Parse(ReadToEnd());
|
|
}
|
|
|
|
private string Parse(Result rs)
|
|
{
|
|
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));
|
|
}
|
|
}
|
|
}
|