sourcegit/src/Commands/QueryGitDir.cs

27 lines
614 B
C#
Raw Normal View History

using System.IO;
2021-04-29 05:05:55 -07:00
namespace SourceGit.Commands
{
public class QueryGitDir : Command
{
public QueryGitDir(string workDir)
{
WorkingDirectory = workDir;
2021-04-29 05:05:55 -07:00
Args = "rev-parse --git-dir";
RaiseError = false;
2021-04-29 05:05:55 -07:00
}
public string Result()
{
var rs = ReadToEnd().StdOut;
if (string.IsNullOrEmpty(rs))
return null;
2021-04-29 05:05:55 -07:00
rs = rs.Trim();
if (Path.IsPathRooted(rs))
return rs;
return Path.GetFullPath(Path.Combine(WorkingDirectory, rs));
2021-04-29 05:05:55 -07:00
}
}
}