Skip to content

Commit

Permalink
#20
Browse files Browse the repository at this point in the history
  • Loading branch information
sboulema committed Mar 29, 2017
1 parent c5c828f commit 2717d9c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions TSVN/Helpers/CommandHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ public static string GetRepositoryRoot(string path = "")
// Try to found the current working folder, either by open document or by open solution
if (string.IsNullOrEmpty(path))
{
if (Dte.ActiveDocument != null)
if (!string.IsNullOrEmpty(Dte.Solution.FileName))
{
path = Path.GetDirectoryName(Dte.ActiveDocument.FullName);
path = Path.GetDirectoryName(Dte.Solution.FullName);
}
else if (!string.IsNullOrEmpty(Dte.Solution.FileName))
else if (Dte.ActiveDocument != null)
{
path = Path.GetDirectoryName(Dte.Solution.FullName);
path = Path.GetDirectoryName(Dte.ActiveDocument.FullName);
}
}

Expand All @@ -86,16 +86,24 @@ public static string GetRepositoryRoot(string path = "")
}
};
proc.Start();

var workingCopyRootPath = string.Empty;
var relativeUrl = string.Empty;

while (!proc.StandardOutput.EndOfStream)
{
var line = proc.StandardOutput.ReadLine();
if (line?.StartsWith("Repository Root:") ?? false)
if (line?.StartsWith("Working Copy Root Path:") ?? false)
{
workingCopyRootPath = line.Substring(24);
}
else if (line?.StartsWith("Relative URL:") ?? false)
{
return new Uri(line.Substring(17)).LocalPath;
relativeUrl = line.Substring(14);
}
}

return string.Empty;
return Path.Combine(workingCopyRootPath, relativeUrl.Substring(2));
}

private static void StartProcess(string application, string args)
Expand Down

0 comments on commit 2717d9c

Please sign in to comment.