public static CheckoutResult Checkout(this SvnCommand svnCommand, string repositoryUrl, string localDirectoryPath) { svnCommand.Logger.LogDebug($"SVN checkout of '{repositoryUrl}' to '{localDirectoryPath}'..."); // Need to ensure the local directory path is NOT directory indicated (does NOT end with a directory separator). var correctedLocalDirectoryPath = PathUtilities.EnsureFilePathNotDirectoryIndicated(localDirectoryPath); var arguments = SvnCommandServicesProvider.GetCheckoutArguments(repositoryUrl, correctedLocalDirectoryPath); var commandOutput = SvnCommandServicesProvider.Run(svnCommand.SvnExecutableFilePath, arguments); var lines = commandOutput.GetOutputLines().ToList(); var lastLine = lines.Last(); var lastLineTokens = lastLine.Split(' '); var revisionNumberToken = lastLineTokens.Last().TrimEnd('.'); var revisionNumber = Int32.Parse(revisionNumberToken); var entryUpdateLines = lines.ExceptLast(); var statuses = new List <EntryUpdateStatus>(); foreach (var line in entryUpdateLines) { var lineTokens = line.Split(new[] { " " }, 2, StringSplitOptions.RemoveEmptyEntries); var statusToken = lineTokens[0]; var relativePath = lineTokens[1]; var updateStatus = statusToken.ToUpdateStatus(); var status = new EntryUpdateStatus { UpdateStatus = updateStatus, RelativePath = relativePath, }; statuses.Add(status); } var result = new CheckoutResult { RevisionNumber = revisionNumber, Statuses = statuses.ToArray(), }; svnCommand.Logger.LogInformation($"SVN checkout of '{repositoryUrl}' to '{localDirectoryPath}' complete."); return(result); }
public static IArgumentsBuilder GetCheckoutArguments(Uri repositoryUrl, AbsolutePath localDirectoryPath) { var argumentsBuilder = SvnCommandServicesProvider.GetCheckoutArguments(repositoryUrl.ToString(), localDirectoryPath.Value); return(argumentsBuilder); }