// // Gets the root path for this repository // public static string GetRoot(string path) { // Clean the path path = Paths.Clean(path); // Check it's not invalid Paths.Type type = Paths.GetType(path); if (type == Paths.Type.None) { return(null); } // If it's a file, get the directory if (type == Paths.Type.File) { path = Path.GetDirectoryName(path); } // Run the svn info command on this path string commandOption = string.Format("info \"{0}\"", path); Process.Output svnOutput = Process.Start(null, "svn", commandOption); // If we have errors, we can't use it if (string.IsNullOrWhiteSpace(svnOutput.StdErr) == false) { return(null); } // We have some properties, so pull out what we're interested in string[] parsedOutput = svnOutput.StdOut.Split('\n'); foreach (string line in parsedOutput) { string lineToFind = "Working Copy Root Path:"; // If we can find it, remove it and return if (line.StartsWith(lineToFind) == true) { return(line.Remove(0, lineToFind.Length).Trim()); } } // Can't find the root return(null); }
// // Returns if the given path is under SVN control // public static bool IsPathTracked(string path) { // Clean the path path = Paths.Clean(path); // Folder or file? Paths.Type pathType = Paths.GetType(path); if (pathType == Paths.Type.None) { return(false); } // Check for a folder or file if (pathType == Paths.Type.Directory) { return(IsFolderTracked(path)); } else { return(IsFileTracked(path)); } }