public static int Update(FilePath svnExecutableFilePath, AbsolutePath path, ILogger logger) { var nonDirectoryIndicatedPath = PathUtilities.EnsurePathIsNotDirectoryIndicated(path.Value).AsAbsolutePath(); logger.LogDebug($"SVN updating {path}..."); // Use the specified path. var arguments = $@"update ""{nonDirectoryIndicatedPath}"""; // Use the non-directory indicated path. var outputCollector = SvnCommandServicesProvider.Run(svnExecutableFilePath, arguments); var lines = new List <string>(); using (var reader = outputCollector.GetOutputReader()) { while (!reader.ReadLineIsEnd(out var line)) { lines.Add(line); } } var lastLine = lines.Last(); var trimmedLastLine = lastLine.TrimEnd('.'); var tokens = trimmedLastLine.Split(' '); var revisionNumber = tokens[tokens.Length - 1]; var revision = Int32.Parse(revisionNumber); logger.LogInformation($"SVN updated {path}.\nRevision: {revision}"); return(revision); }
/// <summary> /// Robustly determines the SVN status of a path using the output of the SVN status command. /// Handles both files and directories, in the case of a directory the status of the directory only, and not all the file-system entries within it. /// Handles warnings by turning them into into the associated <see cref="ItemStatus"/> value. /// Resolves the ambiguous <see cref="ItemStatus.NotFound"/> item status by walking up the path hierarchy until an items status is found. /// </summary> public static SvnStringPathStatus StatusRobust(this SvnCommand svnCommand, AbsolutePath path) { var nonDirectoryIndicatedPath = PathUtilities.EnsurePathIsNotDirectoryIndicated(path.Value).AsAbsolutePath(); var status = svnCommand.StatusRobust_Internal(nonDirectoryIndicatedPath); if (status.ItemStatus != ItemStatus.NotFound) { return(status); } // Determine whether the item is in 1) an ignored directory or 2) an unversioned directory by walking up the path hierarchy until var parentItemStatus = ItemStatus.None; var parentPath = path; do { parentPath = PathUtilities.GetParentDirectoryPath(parentPath); var parentStatus = svnCommand.StatusRobust_Internal(parentPath); parentItemStatus = parentStatus.ItemStatus; }while (parentItemStatus == ItemStatus.NotFound); var output = new SvnStringPathStatus { Path = path.Value, ItemStatus = parentItemStatus }; return(output); }