sourcegit/src/SourceGit/Commands/QueryGitDir.cs

24 lines
581 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;
2021-04-29 05:05:55 -07:00
if (string.IsNullOrEmpty(rs)) return null;
rs = rs.Trim();
if (Path.IsPathRooted(rs)) return rs;
return Path.GetFullPath(Path.Combine(WorkingDirectory, rs));
2021-04-29 05:05:55 -07:00
}
}
}