From db020b5971503066254e0a59444e7e0362f1aec6 Mon Sep 17 00:00:00 2001 From: Ben Floyd Date: Thu, 8 Aug 2019 14:10:24 -0400 Subject: [PATCH 1/2] Deleting health verb --- .../EnlistmentHealthCalculator.cs | 162 ---------- .../HealthCalculator/EnlistmentHealthData.cs | 55 ---- .../HealthCalculator/EnlistmentPathData.cs | 50 --- .../Tests/EnlistmentPerFixture/HealthTests.cs | 264 ---------------- .../Common/GVFSEnlistmentHealthTests.cs | 293 ------------------ GVFS/GVFS/CommandLine/HealthVerb.cs | 217 ------------- GVFS/GVFS/GVFS.Windows.csproj | 1 - GVFS/GVFS/Program.cs | 1 - 8 files changed, 1043 deletions(-) delete mode 100644 GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthCalculator.cs delete mode 100644 GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthData.cs delete mode 100644 GVFS/GVFS.Common/HealthCalculator/EnlistmentPathData.cs delete mode 100644 GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs delete mode 100644 GVFS/GVFS.UnitTests/Common/GVFSEnlistmentHealthTests.cs delete mode 100644 GVFS/GVFS/CommandLine/HealthVerb.cs diff --git a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthCalculator.cs b/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthCalculator.cs deleted file mode 100644 index f4d7a278e5..0000000000 --- a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthCalculator.cs +++ /dev/null @@ -1,162 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace GVFS.Common -{ - /// - /// Class responsible for the business logic involved in calculating the health statistics - /// of a gvfs enlistment. Constructed with the lists of paths for the enlistment, and then - /// internally stores the calculated information. Compute or recompute via CalculateStatistics - /// with an optional parameter to only look for paths which are under the specified directory - /// - public class EnlistmentHealthCalculator - { - // In the context of this class, hydrated files are placeholders or modified paths - // The total number of hydrated files is this.PlaceholderCount + this.ModifiedPathsCount - private readonly EnlistmentPathData enlistmentPathData; - - public EnlistmentHealthCalculator(EnlistmentPathData pathData) - { - this.enlistmentPathData = pathData; - } - - public EnlistmentHealthData CalculateStatistics(string parentDirectory) - { - int gitTrackedItemsCount = 0; - int placeholderCount = 0; - int modifiedPathsCount = 0; - Dictionary gitTrackedItemsDirectoryTally = new Dictionary(StringComparer.OrdinalIgnoreCase); - Dictionary hydratedFilesDirectoryTally = new Dictionary(StringComparer.OrdinalIgnoreCase); - - // Parent directory is a path relative to the root of the repository which is already in git format - if (!parentDirectory.EndsWith(GVFSConstants.GitPathSeparatorString) && parentDirectory.Length > 0) - { - parentDirectory += GVFSConstants.GitPathSeparator; - } - - if (parentDirectory.StartsWith(GVFSConstants.GitPathSeparatorString)) - { - parentDirectory = parentDirectory.TrimStart(GVFSConstants.GitPathSeparator); - } - - gitTrackedItemsCount += this.CategorizePaths(this.enlistmentPathData.GitFolderPaths, gitTrackedItemsDirectoryTally, parentDirectory); - gitTrackedItemsCount += this.CategorizePaths(this.enlistmentPathData.GitFilePaths, gitTrackedItemsDirectoryTally, parentDirectory); - placeholderCount += this.CategorizePaths(this.enlistmentPathData.PlaceholderFolderPaths, hydratedFilesDirectoryTally, parentDirectory); - placeholderCount += this.CategorizePaths(this.enlistmentPathData.PlaceholderFilePaths, hydratedFilesDirectoryTally, parentDirectory); - modifiedPathsCount += this.CategorizePaths(this.enlistmentPathData.ModifiedFolderPaths, hydratedFilesDirectoryTally, parentDirectory); - modifiedPathsCount += this.CategorizePaths(this.enlistmentPathData.ModifiedFilePaths, hydratedFilesDirectoryTally, parentDirectory); - - Dictionary mostHydratedDirectories = new Dictionary(StringComparer.OrdinalIgnoreCase); - - // Map directory names to the corresponding health data from gitTrackedItemsDirectoryTally and hydratedFilesDirectoryTally - foreach (KeyValuePair pair in gitTrackedItemsDirectoryTally) - { - if (hydratedFilesDirectoryTally.TryGetValue(pair.Key, out int hydratedFiles)) - { - // In-lining this for now until a better "health" calculation is created - // Another possibility is the ability to pass a function to use for health (might not be applicable) - mostHydratedDirectories.Add(pair.Key, hydratedFiles); - } - else - { - mostHydratedDirectories.Add(pair.Key, 0); - } - } - - return new EnlistmentHealthData( - parentDirectory, - gitTrackedItemsCount, - placeholderCount, - modifiedPathsCount, - this.CalculateHealthMetric(placeholderCount + modifiedPathsCount, gitTrackedItemsCount), - mostHydratedDirectories.OrderByDescending(kp => kp.Value).ToList()); - } - - /// - /// Take a file path and get the top level directory from it, or GVFSConstants.GitPathSeparator if it is not in a directory - /// - /// The path to a file to parse for the top level directory containing it - /// A string containing the top level directory from the provided path, or GVFSConstants.GitPathSeparator if the path is for an item in the root - private string ParseTopDirectory(string path) - { - int whackLocation = path.IndexOf(GVFSConstants.GitPathSeparator); - if (whackLocation == -1) - { - return GVFSConstants.GitPathSeparatorString; - } - - return path.Substring(0, whackLocation); - } - - /// - /// Categorizes a list of paths given as strings by mapping them to the top level directory in their path - /// Modifies the directoryTracking dictionary to have an accurate count of the files underneath a top level directory - /// - /// - /// The distinction between files and directories is important -- - /// If the path to a file doesn't contain a GVFSConstants.GitPathSeparator, then that means it falls within the root - /// However if a directory's path doesn't contain a GVFSConstants.GitPathSeparator, it doesn't count towards its own hydration - /// - /// An enumerable containing paths as strings - /// A dictionary used to track the number of files per top level directory - /// Paths will only be categorized if they are descendants of the parentDirectory - private int CategorizePaths(IEnumerable paths, Dictionary directoryTracking, string parentDirectory) - { - int count = 0; - foreach (string path in paths) - { - // Only categorize if descendent of the parentDirectory - if (path.StartsWith(parentDirectory, StringComparison.OrdinalIgnoreCase)) - { - count++; - - // If the path is to the parentDirectory, ignore it to avoid adding string.Empty to the data structures - if (!parentDirectory.Equals(path, StringComparison.OrdinalIgnoreCase)) - { - // Trim the path to parent directory - string topDir = this.ParseTopDirectory(this.TrimDirectoryFromPath(path, parentDirectory)); - if (!topDir.Equals(GVFSConstants.GitPathSeparatorString)) - { - this.IncreaseDictionaryCounterByKey(directoryTracking, topDir); - } - } - } - } - - return count; - } - - /// - /// Trim the relative path to a directory from the front of a specified path which is its child - /// - /// Precondition: 'directoryTarget' must be an ancestor of 'path' - /// The path being trimmed - /// The directory target whose path to trim from the path - /// The newly formatted path with the directory trimmed - private string TrimDirectoryFromPath(string path, string directoryTarget) - { - return path.Substring(directoryTarget.Length); - } - - private void IncreaseDictionaryCounterByKey(Dictionary countingDictionary, string key) - { - if (!countingDictionary.TryGetValue(key, out int count)) - { - count = 0; - } - - countingDictionary[key] = ++count; - } - - private decimal CalculateHealthMetric(int hydratedFileCount, int totalFileCount) - { - if (totalFileCount == 0) - { - return 0; - } - - return (decimal)hydratedFileCount / (decimal)totalFileCount; - } - } -} diff --git a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthData.cs b/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthData.cs deleted file mode 100644 index 9d73df8383..0000000000 --- a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHealthData.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Collections.Generic; - -namespace GVFS.Common -{ - public class EnlistmentHealthData - { - public EnlistmentHealthData( - string targetDirectory, - int gitItemsCount, - int placeholderCount, - int modifiedPathsCount, - decimal healthMetric, - List> directoryHydrationLevels) - { - this.TargetDirectory = targetDirectory; - this.GitTrackedItemsCount = gitItemsCount; - this.PlaceholderCount = placeholderCount; - this.ModifiedPathsCount = modifiedPathsCount; - this.HealthMetric = healthMetric; - this.DirectoryHydrationLevels = directoryHydrationLevels; - } - - public string TargetDirectory { get; private set; } - public int GitTrackedItemsCount { get; private set; } - public int PlaceholderCount { get; private set; } - public int ModifiedPathsCount { get; private set; } - public List> DirectoryHydrationLevels { get; private set; } - public decimal HealthMetric { get; private set; } - public decimal PlaceholderPercentage - { - get - { - if (this.GitTrackedItemsCount == 0) - { - return 0; - } - - return (decimal)this.PlaceholderCount / this.GitTrackedItemsCount; - } - } - - public decimal ModifiedPathsPercentage - { - get - { - if (this.GitTrackedItemsCount == 0) - { - return 0; - } - - return (decimal)this.ModifiedPathsCount / this.GitTrackedItemsCount; - } - } - } -} diff --git a/GVFS/GVFS.Common/HealthCalculator/EnlistmentPathData.cs b/GVFS/GVFS.Common/HealthCalculator/EnlistmentPathData.cs deleted file mode 100644 index a7ecaafae4..0000000000 --- a/GVFS/GVFS.Common/HealthCalculator/EnlistmentPathData.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace GVFS.Common -{ - public class EnlistmentPathData - { - public List GitFolderPaths; - public List GitFilePaths; - public List PlaceholderFolderPaths; - public List PlaceholderFilePaths; - public List ModifiedFolderPaths; - public List ModifiedFilePaths; - public List GitTrackingPaths; - - public EnlistmentPathData() - { - this.GitFolderPaths = new List(); - this.GitFilePaths = new List(); - this.PlaceholderFolderPaths = new List(); - this.PlaceholderFilePaths = new List(); - this.ModifiedFolderPaths = new List(); - this.ModifiedFilePaths = new List(); - this.GitTrackingPaths = new List(); - } - - public void NormalizeAllPaths() - { - this.NormalizePaths(this.GitFolderPaths); - this.NormalizePaths(this.GitFilePaths); - this.NormalizePaths(this.PlaceholderFolderPaths); - this.NormalizePaths(this.PlaceholderFilePaths); - this.NormalizePaths(this.ModifiedFolderPaths); - this.NormalizePaths(this.ModifiedFilePaths); - this.NormalizePaths(this.GitTrackingPaths); - - this.ModifiedFilePaths = this.ModifiedFilePaths.Union(this.GitTrackingPaths).ToList(); - } - - private void NormalizePaths(List paths) - { - for (int i = 0; i < paths.Count; i++) - { - paths[i] = paths[i].Replace(GVFSPlatform.GVFSPlatformConstants.PathSeparator, GVFSConstants.GitPathSeparator); - paths[i] = paths[i].Trim(GVFSConstants.GitPathSeparator); - } - } - } -} diff --git a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs b/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs deleted file mode 100644 index 48c62cc0e1..0000000000 --- a/GVFS/GVFS.FunctionalTests/Tests/EnlistmentPerFixture/HealthTests.cs +++ /dev/null @@ -1,264 +0,0 @@ -using GVFS.FunctionalTests.Tools; -using GVFS.Tests.Should; -using NUnit.Framework; -using NUnit.Framework.Internal; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Text.RegularExpressions; - -namespace GVFS.FunctionalTests.Tests.EnlistmentPerFixture -{ - [TestFixture, Category(Categories.WindowsOnly)] - public class HealthTests : TestsWithEnlistmentPerFixture - { - [TestCase, Order(0)] - public void AfterCloningRepoIsPerfectlyHealthy() - { - // .gitignore is always a placeholder on creation - // .gitconfig is always a modified path in functional tests since it is written at run time - - List topHydratedDirectories = new List { "GVFS", "GVFlt_BugRegressionTest", "GVFlt_DeleteFileTest", "GVFlt_DeleteFolderTest", "GVFlt_EnumTest" }; - List directoryHydrationLevels = new List { 0, 0, 0, 0, 0 }; - - this.ValidateHealthOutputValues( - directory: string.Empty, - totalFiles: 1211, - totalFilePercent: 100, - fastFiles: 1, - fastFilePercent: 0, - slowFiles: 1, - slowFilePercent: 0, - totalPercent: 0, - topHydratedDirectories: topHydratedDirectories, - directoryHydrationLevels: directoryHydrationLevels, - enlistmentHealthStatus: "OK"); - } - - [TestCase, Order(1)] - public void PlaceholdersChangeHealthScores() - { - // Hydrate all files in the Scripts/ directory as placeholders - // This creates 6 placeholders, 5 files along with the Scripts/ directory - this.HydratePlaceholder(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonAssemblyVersion.bat")); - this.HydratePlaceholder(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonCliAssemblyVersion.bat")); - this.HydratePlaceholder(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonVersionHeader.bat")); - this.HydratePlaceholder(Path.Combine(this.Enlistment.RepoRoot, "Scripts/RunFunctionalTests.bat")); - this.HydratePlaceholder(Path.Combine(this.Enlistment.RepoRoot, "Scripts/RunUnitTests.bat")); - - List topHydratedDirectories = new List { "Scripts", "GVFS", "GVFlt_BugRegressionTest", "GVFlt_DeleteFileTest", "GVFlt_DeleteFolderTest" }; - List directoryHydrationLevels = new List { 5, 0, 0, 0, 0 }; - - this.ValidateHealthOutputValues( - directory: string.Empty, - totalFiles: 1211, - totalFilePercent: 100, - fastFiles: 7, - fastFilePercent: 1, - slowFiles: 1, - slowFilePercent: 0, - totalPercent:1, - topHydratedDirectories: topHydratedDirectories, - directoryHydrationLevels: directoryHydrationLevels, - enlistmentHealthStatus: "OK"); - } - - [TestCase, Order(2)] - public void ModifiedPathsChangeHealthScores() - { - // Hydrate all files in GVFlt_FileOperationTest as modified paths - // This creates 2 modified paths and one placeholder - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "GVFlt_FileOperationTest/DeleteExistingFile.txt")); - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "GVFlt_FileOperationTest/WriteAndVerify.txt")); - - List topHydratedDirectories = new List { "Scripts", "GVFlt_FileOperationTest", "GVFS", "GVFlt_BugRegressionTest", "GVFlt_DeleteFileTest" }; - List directoryHydrationLevels = new List { 5, 2, 0, 0, 0 }; - - this.ValidateHealthOutputValues( - directory: string.Empty, - totalFiles: 1211, - totalFilePercent: 100, - fastFiles: 8, - fastFilePercent: 1, - slowFiles: 3, - slowFilePercent: 0, - totalPercent: 1, - topHydratedDirectories: topHydratedDirectories, - directoryHydrationLevels: directoryHydrationLevels, - enlistmentHealthStatus: "OK"); - } - - [TestCase, Order(3)] - public void TurnPlaceholdersIntoModifiedPaths() - { - // Hydrate the files in Scripts/ from placeholders to modified paths - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonAssemblyVersion.bat")); - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonCliAssemblyVersion.bat")); - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "Scripts/CreateCommonVersionHeader.bat")); - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "Scripts/RunFunctionalTests.bat")); - this.HydrateFullFile(Path.Combine(this.Enlistment.RepoRoot, "Scripts/RunUnitTests.bat")); - - List topHydratedDirectories = new List { "Scripts", "GVFlt_FileOperationTest", "GVFS", "GVFlt_BugRegressionTest", "GVFlt_DeleteFileTest" }; - List directoryHydrationLevels = new List { 5, 2, 0, 0, 0 }; - - this.ValidateHealthOutputValues( - directory: string.Empty, - totalFiles: 1211, - totalFilePercent: 100, - fastFiles: 3, - fastFilePercent: 0, - slowFiles: 8, - slowFilePercent: 1, - totalPercent: 1, - topHydratedDirectories: topHydratedDirectories, - directoryHydrationLevels: directoryHydrationLevels, - enlistmentHealthStatus: "OK"); - } - - [TestCase, Order(4)] - public void FilterIntoDirectory() - { - List topHydratedDirectories = new List(); - List directoryHydrationLevels = new List(); - - this.ValidateHealthOutputValues( - directory: "Scripts/", - totalFiles: 5, - totalFilePercent: 100, - fastFiles: 0, - fastFilePercent: 0, - slowFiles: 5, - slowFilePercent: 100, - totalPercent: 100, - topHydratedDirectories: topHydratedDirectories, - directoryHydrationLevels: directoryHydrationLevels, - enlistmentHealthStatus: "Highly Hydrated"); - } - - private void HydratePlaceholder(string filePath) - { - File.ReadAllText(filePath); - } - - private void HydrateFullFile(string filePath) - { - File.OpenWrite(filePath).Close(); - } - - private void ValidateHealthOutputValues( - string directory, - int totalFiles, - int totalFilePercent, - int fastFiles, - int fastFilePercent, - int slowFiles, - int slowFilePercent, - int totalPercent, - List topHydratedDirectories, - List directoryHydrationLevels, - string enlistmentHealthStatus) - { - List healthOutputLines = new List(this.Enlistment.Health(directory).Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)); - - int numberOfExpectedSubdirectories = topHydratedDirectories.Count; - - this.ValidateTargetDirectory(healthOutputLines[1], directory); - this.ValidateTotalFileInfo(healthOutputLines[2], totalFiles, totalFilePercent); - this.ValidateFastFileInfo(healthOutputLines[3], fastFiles, fastFilePercent); - this.ValidateSlowFileInfo(healthOutputLines[4], slowFiles, slowFilePercent); - this.ValidateTotalHydration(healthOutputLines[5], totalPercent); - this.ValidateSubDirectoryHealth(healthOutputLines.GetRange(7, numberOfExpectedSubdirectories), topHydratedDirectories, directoryHydrationLevels); - this.ValidateEnlistmentStatus(healthOutputLines[7 + numberOfExpectedSubdirectories], enlistmentHealthStatus); - } - - private void ValidateTargetDirectory(string outputLine, string targetDirectory) - { - // Regex to extract the target directory - // "Health of directory: " - Match lineMatch = Regex.Match(outputLine, @"^Health of directory:\s*(.*)$"); - - string outputtedTargetDirectory = lineMatch.Groups[1].Value; - - outputtedTargetDirectory.ShouldEqual(targetDirectory); - } - - private void ValidateTotalFileInfo(string outputLine, int totalFiles, int totalFilePercent) - { - // Regex to extract the total number of files and percentage they represent (should always be 100) - // "Total files in HEAD commit: | %" - Match lineMatch = Regex.Match(outputLine, @"^Total files in HEAD commit:\s*([\d,]+)\s*\|\s*(\d+)%$"); - - int.TryParse(lineMatch.Groups[1].Value, NumberStyles.AllowThousands, CultureInfo.CurrentCulture.NumberFormat, out int outputtedTotalFiles).ShouldBeTrue(); - int.TryParse(lineMatch.Groups[2].Value, out int outputtedTotalFilePercent).ShouldBeTrue(); - - outputtedTotalFiles.ShouldEqual(totalFiles); - outputtedTotalFilePercent.ShouldEqual(totalFilePercent); - } - - private void ValidateFastFileInfo(string outputLine, int fastFiles, int fastFilesPercent) - { - // Regex to extract the total number of fast files and percentage they represent - // "Files managed by VFS for Git (fast): | %" - Match lineMatch = Regex.Match(outputLine, @"^Files managed by VFS for Git \(fast\):\s*([\d,]+)\s*\|\s*(\d+)%$"); - - int.TryParse(lineMatch.Groups[1].Value, NumberStyles.AllowThousands, CultureInfo.CurrentCulture.NumberFormat, out int outputtedFastFiles).ShouldBeTrue(); - int.TryParse(lineMatch.Groups[2].Value, out int outputtedFastFilesPercent).ShouldBeTrue(); - - outputtedFastFiles.ShouldEqual(fastFiles); - outputtedFastFilesPercent.ShouldEqual(fastFilesPercent); - } - - private void ValidateSlowFileInfo(string outputLine, int slowFiles, int slowFilesPercent) - { - // Regex to extract the total number of slow files and percentage they represent - // "Files managed by git (slow): | %" - Match lineMatch = Regex.Match(outputLine, @"^Files managed by Git:\s*([\d,]+)\s*\|\s*(\d+)%$"); - - int.TryParse(lineMatch.Groups[1].Value, NumberStyles.AllowThousands, CultureInfo.CurrentCulture.NumberFormat, out int outputtedSlowFiles).ShouldBeTrue(); - int.TryParse(lineMatch.Groups[2].Value, out int outputtedSlowFilesPercent).ShouldBeTrue(); - - outputtedSlowFiles.ShouldEqual(slowFiles); - outputtedSlowFilesPercent.ShouldEqual(slowFilesPercent); - } - - private void ValidateTotalHydration(string outputLine, int totalHydration) - { - // Regex to extract the total hydration percentage of the enlistment - // "Total hydration percentage: % - Match lineMatch = Regex.Match(outputLine, @"^Total hydration percentage:\s*(\d+)%$"); - - int.TryParse(lineMatch.Groups[1].Value, out int outputtedTotalHydration).ShouldBeTrue(); - - outputtedTotalHydration.ShouldEqual(totalHydration); - } - - private void ValidateSubDirectoryHealth(List outputLines, List subdirectories, List healthScores) - { - for (int i = 0; i < outputLines.Count; i++) - { - // Regex to extract the most hydrated subdirectory names and their hydration percentage - // " | " listed several times for different directories - Match lineMatch = Regex.Match(outputLines[i], @"^\s*([\d,]+)\s*\|\s*(\S.*\S)\s*$"); - - int.TryParse(lineMatch.Groups[1].Value, NumberStyles.AllowThousands, CultureInfo.CurrentCulture.NumberFormat, out int outputtedHealthScore).ShouldBeTrue(); - string outputtedSubdirectory = lineMatch.Groups[2].Value; - - outputtedHealthScore.ShouldEqual(healthScores[i]); - outputtedSubdirectory.ShouldEqual(subdirectories[i]); - } - } - - private void ValidateEnlistmentStatus(string outputLine, string statusMessage) - { - // Regex to extract the status message for the enlistment - // "Repository status: " - Match lineMatch = Regex.Match(outputLine, @"^Repository status:\s*(.*)$"); - - string outputtedStatusMessage = lineMatch.Groups[1].Value; - - outputtedStatusMessage.ShouldEqual(statusMessage); - } - } -} diff --git a/GVFS/GVFS.UnitTests/Common/GVFSEnlistmentHealthTests.cs b/GVFS/GVFS.UnitTests/Common/GVFSEnlistmentHealthTests.cs deleted file mode 100644 index fda6e03a43..0000000000 --- a/GVFS/GVFS.UnitTests/Common/GVFSEnlistmentHealthTests.cs +++ /dev/null @@ -1,293 +0,0 @@ -using GVFS.Common; -using GVFS.Tests.Should; -using NUnit.Framework; - -namespace GVFS.UnitTests.Common -{ - [TestFixture] - public class GVFSEnlistmentHealthTests - { - private readonly char sep = GVFSPlatform.GVFSPlatformConstants.PathSeparator; - private EnlistmentHealthCalculator enlistmentHealthCalculator; - private EnlistmentHealthData enlistmentHealthData; - - [TestCase] - public void SingleHydratedDirectoryShouldHaveOtherDirectoriesCompletelyHealthy() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("A/1.js", "A/2.js", "A/3.js", "A/4.js", "B/1.js", "B/2.js", "B/3.js", "B/4.js", "C/1.js", "C/2.js", "C/3.js", "C/4.js") - .AddPlaceholderFiles("A/1.js", "A/2.js", "A/3.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.DirectoryHydrationLevels[0].Key.ShouldEqual("A"); - this.enlistmentHealthData.DirectoryHydrationLevels[0].Value.ShouldEqual(3); - this.enlistmentHealthData.DirectoryHydrationLevels[1].Key.ShouldEqual("B"); - this.enlistmentHealthData.DirectoryHydrationLevels[1].Value.ShouldEqual(0); - this.enlistmentHealthData.DirectoryHydrationLevels[2].Key.ShouldEqual("C"); - this.enlistmentHealthData.DirectoryHydrationLevels[2].Value.ShouldEqual(0); - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(pathData.GitFilePaths.Count); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(0); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual((decimal)pathData.PlaceholderFilePaths.Count / (decimal)pathData.GitFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(0); - } - - [TestCase] - public void AllEmptyLists() - { - EnlistmentPathData pathData = new PathDataBuilder() - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(0); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(0); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(0); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(0); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(0); - } - - [TestCase] - public void OverHydrated() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("A/1.js", "A/2.js", "A/3.js", "A/4.js", "B/1.js", "B/2.js", "B/3.js", "B/4.js", "C/1.js", "C/2.js", "C/3.js", "C/4.js") - .AddPlaceholderFiles("A/1.js", "A/2.js", "A/3.js", "A/4.js", "B/1.js", "B/2.js", "B/3.js", "B/4.js", "C/1.js", "C/2.js", "C/3.js", "C/4.js") - .AddModifiedPathFiles("A/1.js", "A/2.js", "A/3.js", "A/4.js", "B/1.js", "B/2.js", "B/3.js", "B/4.js", "C/1.js", "C/2.js", "C/3.js", "C/4.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(pathData.GitFilePaths.Count); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(pathData.ModifiedFilePaths.Count); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(1); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(1); - } - - [TestCase] - public void SortByHydration() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("C/1.js", "A/1.js", "B/1.js", "B/2.js", "A/2.js", "C/2.js", "A/3.js", "C/3.js", "B/3.js") - .AddModifiedPathFiles("C/1.js", "B/2.js", "A/3.js") - .AddPlaceholderFiles("B/1.js", "A/2.js") - .AddModifiedPathFiles("A/1.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(pathData.ModifiedFilePaths.Count); - this.enlistmentHealthData.DirectoryHydrationLevels[0].Key.ShouldEqual("A"); - this.enlistmentHealthData.DirectoryHydrationLevels[1].Key.ShouldEqual("B"); - this.enlistmentHealthData.DirectoryHydrationLevels[2].Key.ShouldEqual("C"); - } - - [TestCase] - public void VariedDirectoryFormatting() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("A/1.js", "A/2.js", "A/3.js", "B/1.js", "B/2.js", "B/3.js") - .AddPlaceholderFolders("/A/", $"{this.sep}B{this.sep}", "A/", $"B{this.sep}", "/A", $"{this.sep}B", "A", "B") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFolderPaths.Count); - - // If the count of the sorted list is not 2, the different directory formats were considered distinct - this.enlistmentHealthData.DirectoryHydrationLevels.Count.ShouldEqual(2); - } - - [TestCase] - public void VariedFilePathFormatting() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("A/1.js", "A/2.js", "A/3.js", "B/1.js", "B/2.js", "B/3.js") - .AddPlaceholderFiles("A/1.js", $"A{this.sep}2.js", "/A/1.js", $"{this.sep}A{this.sep}1.js") - .AddModifiedPathFiles($"B{this.sep}2.js", $"{this.sep}B{this.sep}1.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(pathData.ModifiedFilePaths.Count); - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(pathData.GitFilePaths.Count); - this.enlistmentHealthData.DirectoryHydrationLevels.Count.ShouldEqual(2); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual((decimal)pathData.PlaceholderFilePaths.Count / (decimal)pathData.GitFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual((decimal)pathData.ModifiedFilePaths.Count / (decimal)pathData.GitFilePaths.Count); - this.enlistmentHealthData.DirectoryHydrationLevels[0].Value.ShouldEqual(4); - this.enlistmentHealthData.DirectoryHydrationLevels[1].Value.ShouldEqual(2); - } - - [TestCase] - public void FilterByDirectory() - { - string[] gitFilesDirectoryA = new string[] { "A/1.js", "A/2.js", "A/3.js" }; - string[] gitFilesDirectoryB = new string[] { "B/1.js", "B/2.js", "B/3.js" }; - - // Duplicate modified paths get cleaned up when unioned with non skip worktree paths from git - // Duplicate placeholders remain as read from the placeholder database to most accurately represent information - - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles(gitFilesDirectoryA) - .AddGitFiles(gitFilesDirectoryB) - .AddPlaceholderFiles("A/1.js", $"A{this.sep}2.js", "/A/1.js", $"{this.sep}A{this.sep}1.js") - .AddModifiedPathFiles("B/1.js", $"B{this.sep}2.js", "/B/1.js", $"{this.sep}B{this.sep}1.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, "A/"); - - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(gitFilesDirectoryA.Length); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(4.0m / 3.0m); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(0); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(0); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, "/B/"); - - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(gitFilesDirectoryB.Length); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(0); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(0); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(pathData.ModifiedFilePaths.Count); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(2.0m / 3.0m); - } - - [TestCase] - public void FilterByDirectoryWithoutPathSeparator() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("Directory1/Child1/File1.js", "Directory1/Child1/File2.exe", "Directory2/Child2/File1.bat", "Directory2/Child2/File2.css") - .AddPlaceholderFiles("Directory1/File1.js", "Directory1/File2.exe", "Directory2/File1.bat", "Directory2/File2.css") - .Build(); - - // With no target should get both directories back - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - this.enlistmentHealthData.DirectoryHydrationLevels.Count.ShouldEqual(2); - - // With a root target ('/') should also get both directories back - this.enlistmentHealthData = this.GenerateStatistics(pathData, GVFSConstants.GitPathSeparatorString); - this.enlistmentHealthData.DirectoryHydrationLevels.Count.ShouldEqual(2); - - // Filtering by a substring of a directory shouldn't get the directories back - this.enlistmentHealthData = this.GenerateStatistics(pathData, "Directory"); - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(0); - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(0); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(0); - } - - [TestCase] - public void EnsureFolderNotIncludedInOwnCount() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFolders("foo/") - .AddGitFiles("foo/file1.jpg", "foo/file2.jpg", "foo/file3.jpg", "foo/file4.jpg", "foo/file5.jpg") - .AddPlaceholderFiles("foo/file1.jpg", "foo/file2.jpg", "foo/file3.jpg", "foo/file4.jpg", "foo/file5.jpg") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - this.enlistmentHealthData.DirectoryHydrationLevels[0].Value.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count); - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(pathData.GitFilePaths.Count + pathData.GitFolderPaths.Count); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(5m / 6m); - } - - [TestCase] - public void FolderNotDoubleCounted() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFolders("foo/") - .AddGitFiles("foo/file1.jpg", "foo/file2.jpg", "foo/file3.jpg", "foo/file4.jpg", "foo/file5.jpg") - .AddPlaceholderFiles("foo/file1.jpg", "foo/file2.jpg", "foo/file3.jpg", "foo/file4.jpg", "foo/file5.jpg") - .AddPlaceholderFolders("/foo") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - this.enlistmentHealthData.DirectoryHydrationLevels[0].Value.ShouldEqual(5); - this.enlistmentHealthData.PlaceholderCount.ShouldEqual(pathData.PlaceholderFilePaths.Count + pathData.PlaceholderFolderPaths.Count); - this.enlistmentHealthData.GitTrackedItemsCount.ShouldEqual(pathData.GitFilePaths.Count + pathData.GitFolderPaths.Count); - this.enlistmentHealthData.PlaceholderPercentage.ShouldEqual(1); - } - - [TestCase] - public void UnionOfSkipWorktreeAndModifiedPathsNoDuplicates() - { - EnlistmentPathData pathData = new PathDataBuilder() - .AddGitFiles("A/1.js", "A/2.js", "A/3.js", "B/1.js", "B/2.js", "B/3.js") - .AddModifiedPathFiles("A/1.js", "A/2.js", "/A/3.js", "B/1.js", "B/2.js", "B/3.js") - .AddNonSkipWorktreeFiles("A/1.js", "/A/2.js", $"{this.sep}A/3.js", "B/1.js", $"B{this.sep}2.js", $"/B{this.sep}3.js") - .Build(); - - this.enlistmentHealthData = this.GenerateStatistics(pathData, string.Empty); - - // ModifiedPaths are unioned with NonSkipWorktreePaths to get a total count of fully git tracked files - // The six ModifiedPaths overlap with the six NonSkipWorktreePaths, so only 6 should be counted - this.enlistmentHealthData.ModifiedPathsCount.ShouldEqual(6); - this.enlistmentHealthData.ModifiedPathsPercentage.ShouldEqual(1); - this.enlistmentHealthData.DirectoryHydrationLevels.Count.ShouldEqual(2); - } - - private EnlistmentHealthData GenerateStatistics(EnlistmentPathData pathData, string directory) - { - this.enlistmentHealthCalculator = new EnlistmentHealthCalculator(pathData); - return this.enlistmentHealthCalculator.CalculateStatistics(directory); - } - - public class PathDataBuilder - { - private EnlistmentPathData pathData = new EnlistmentPathData(); - - public PathDataBuilder AddPlaceholderFiles(params string[] placeholderFilePaths) - { - this.pathData.PlaceholderFilePaths.AddRange(placeholderFilePaths); - return this; - } - - public PathDataBuilder AddPlaceholderFolders(params string[] placeholderFolderPaths) - { - this.pathData.PlaceholderFolderPaths.AddRange(placeholderFolderPaths); - return this; - } - - public PathDataBuilder AddModifiedPathFiles(params string[] modifiedFilePaths) - { - this.pathData.ModifiedFilePaths.AddRange(modifiedFilePaths); - return this; - } - - public PathDataBuilder AddModifiedPathFolders(params string[] modifiedFolderPaths) - { - this.pathData.ModifiedFolderPaths.AddRange(modifiedFolderPaths); - return this; - } - - public PathDataBuilder AddGitFiles(params string[] gitFilePaths) - { - this.pathData.GitFilePaths.AddRange(gitFilePaths); - return this; - } - - public PathDataBuilder AddGitFolders(params string[] gitFolderPaths) - { - this.pathData.GitFolderPaths.AddRange(gitFolderPaths); - return this; - } - - public PathDataBuilder AddNonSkipWorktreeFiles(params string[] nonSkipWorktreeFiles) - { - this.pathData.GitTrackingPaths.AddRange(nonSkipWorktreeFiles); - return this; - } - - public EnlistmentPathData Build() - { - this.pathData.NormalizeAllPaths(); - return this.pathData; - } - } - } -} diff --git a/GVFS/GVFS/CommandLine/HealthVerb.cs b/GVFS/GVFS/CommandLine/HealthVerb.cs deleted file mode 100644 index 2d487369d5..0000000000 --- a/GVFS/GVFS/CommandLine/HealthVerb.cs +++ /dev/null @@ -1,217 +0,0 @@ -using CommandLine; -using GVFS.Common; -using GVFS.Common.Git; -using GVFS.Common.NamedPipes; -using System; -using System.Collections.Generic; -using System.Linq; - -namespace GVFS.CommandLine -{ - [Verb(HealthVerb.HealthVerbName, HelpText = "EXPERIMENTAL FEATURE - Measure the health of the repository")] - public class HealthVerb : GVFSVerb.ForExistingEnlistment - { - private const string HealthVerbName = "health"; - private const decimal MaximumHealthyHydration = 0.5m; - - [Option( - 'n', - Required = false, - HelpText = "Only display the most hydrated directories in the output")] - public int DirectoryDisplayCount { get; set; } = 5; - - [Option( - 'd', - "directory", - Required = false, - HelpText = "Get the health of a specific directory (default is the current working directory")] - public string Directory { get; set; } - - protected override string VerbName => HealthVerbName; - - protected override void Execute(GVFSEnlistment enlistment) - { - // Now default to the current working directory when running the verb without a specified path - if (string.IsNullOrEmpty(this.Directory) || this.Directory.Equals(".")) - { - if (Environment.CurrentDirectory.StartsWith(enlistment.WorkingDirectoryRoot, StringComparison.OrdinalIgnoreCase)) - { - this.Directory = Environment.CurrentDirectory.Substring(enlistment.WorkingDirectoryRoot.Length); - } - else - { - // If the path is not under the source root, set the directory to empty - this.Directory = string.Empty; - } - } - - this.Output.WriteLine("\nGathering repository data..."); - - this.Directory = this.Directory.Replace(GVFSPlatform.GVFSPlatformConstants.PathSeparator, GVFSConstants.GitPathSeparator); - - EnlistmentPathData pathData = new EnlistmentPathData(); - - this.GetModifiedPathsFromPipe(enlistment, pathData); - this.GetPathsFromGitIndex(enlistment, pathData); - - pathData.NormalizeAllPaths(); - - EnlistmentHealthCalculator enlistmentHealthCalculator = new EnlistmentHealthCalculator(pathData); - EnlistmentHealthData enlistmentHealthData = enlistmentHealthCalculator.CalculateStatistics(this.Directory); - - this.PrintOutput(enlistmentHealthData); - } - - private void PrintOutput(EnlistmentHealthData enlistmentHealthData) - { - string trackedFilesCountFormatted = enlistmentHealthData.GitTrackedItemsCount.ToString("N0"); - string placeholderCountFormatted = enlistmentHealthData.PlaceholderCount.ToString("N0"); - string modifiedPathsCountFormatted = enlistmentHealthData.ModifiedPathsCount.ToString("N0"); - - // Calculate spacing for the numbers of total files - int longest = Math.Max(trackedFilesCountFormatted.Length, placeholderCountFormatted.Length); - longest = Math.Max(longest, modifiedPathsCountFormatted.Length); - - // Sort the dictionary to find the most hydrated directories by health score - List> topLevelDirectoriesByHydration = enlistmentHealthData.DirectoryHydrationLevels.Take(this.DirectoryDisplayCount).ToList(); - - this.Output.WriteLine("\nHealth of directory: " + enlistmentHealthData.TargetDirectory); - this.Output.WriteLine("Total files in HEAD commit: " + trackedFilesCountFormatted.PadLeft(longest) + " | 100%"); - this.Output.WriteLine("Files managed by VFS for Git (fast): " + placeholderCountFormatted.PadLeft(longest) + " | " + this.FormatPercent(enlistmentHealthData.PlaceholderPercentage)); - this.Output.WriteLine("Files managed by Git: " + modifiedPathsCountFormatted.PadLeft(longest) + " | " + this.FormatPercent(enlistmentHealthData.ModifiedPathsPercentage)); - - this.Output.WriteLine("\nTotal hydration percentage: " + this.FormatPercent(enlistmentHealthData.PlaceholderPercentage + enlistmentHealthData.ModifiedPathsPercentage).PadLeft(longest + 7)); - - this.Output.WriteLine("\nMost hydrated top level directories:"); - - int maxCountLength = 0; - foreach (KeyValuePair pair in topLevelDirectoriesByHydration) - { - maxCountLength = Math.Max(maxCountLength, pair.Value.ToString("N0").Length); - } - - foreach (KeyValuePair pair in topLevelDirectoriesByHydration) - { - this.Output.WriteLine(" " + pair.Value.ToString("N0").PadLeft(maxCountLength) + " | " + pair.Key); - } - - bool healthyRepo = (enlistmentHealthData.PlaceholderPercentage + enlistmentHealthData.ModifiedPathsPercentage) < MaximumHealthyHydration; - - this.Output.WriteLine("\nRepository status: " + (healthyRepo ? "OK" : "Highly Hydrated")); - } - - /// - /// Takes a fractional decimal and formats it as a percent taking exactly 4 characters with no decimals - /// - /// Fractional decimal to format to a percent - /// A 4 character string formatting the percent correctly - private string FormatPercent(decimal percent) - { - return percent.ToString("P0").PadLeft(4); - } - - /// - /// Parse a line of the git index coming from the ls-tree endpoint in the git process to get the path to that file - /// - /// The line from the output of the git index - /// The path extracted from the provided line of the git index - private string TrimGitIndexLine(string line) - { - return line.Substring(line.IndexOf('\t') + 1); - } - - /// - /// Parse a line of the git index coming from the ls-files endpoint in the git process to get the path to that files - /// These paths begin with 'S' or 'H' depending on if they have the skip-worktree bit set - /// - /// The line from the output of the git index - /// The path extracted from the provided line of the git index - private string TrimGitIndexLineWithSkipWorktree(string line) - { - return line.Substring(line.IndexOf(' ') + 1); - } - - /// - /// Talk to the mount process across the named pipe to get a list of the modified paths - /// - /// If/when modified paths are moved to SQLite go there instead - /// The enlistment being operated on - /// An array containing all of the modified paths in string format - private void GetModifiedPathsFromPipe(GVFSEnlistment enlistment, EnlistmentPathData pathData) - { - using (NamedPipeClient pipeClient = new NamedPipeClient(enlistment.NamedPipeName)) - { - string[] modifiedPathsList = Array.Empty(); - - if (!pipeClient.Connect()) - { - this.ReportErrorAndExit("Unable to connect to GVFS. Try running 'gvfs mount'"); - } - - try - { - NamedPipeMessages.Message modifiedPathsMessage = new NamedPipeMessages.Message(NamedPipeMessages.ModifiedPaths.ListRequest, NamedPipeMessages.ModifiedPaths.CurrentVersion); - pipeClient.SendRequest(modifiedPathsMessage); - - NamedPipeMessages.Message modifiedPathsResponse = pipeClient.ReadResponse(); - if (!modifiedPathsResponse.Header.Equals(NamedPipeMessages.ModifiedPaths.SuccessResult)) - { - this.Output.WriteLine("Bad response from modified path pipe: " + modifiedPathsResponse.Header); - return; - } - - modifiedPathsList = modifiedPathsResponse.Body.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries); - } - catch (BrokenPipeException e) - { - this.ReportErrorAndExit("Unable to communicate with GVFS: " + e.ToString()); - } - - foreach (string path in modifiedPathsList) - { - if (path.Last() == GVFSConstants.GitPathSeparator) - { - path.TrimEnd(GVFSConstants.GitPathSeparator); - pathData.ModifiedFolderPaths.Add(path); - } - else - { - pathData.ModifiedFilePaths.Add(path); - } - } - } - } - - /// - /// Call 'git ls-files' and 'git ls-tree' to get a list of all files and directories in the enlistment - /// - /// The current GVFS enlistmetn being operated on - /// The path data object where paths are being saved - private void GetPathsFromGitIndex(GVFSEnlistment enlistment, EnlistmentPathData pathData) - { - List skipWorktreeFiles = new List(); - GitProcess gitProcess = new GitProcess(enlistment); - - GitProcess.Result fileResult = gitProcess.LsFiles( - line => - { - if (line.First() == 'H') - { - skipWorktreeFiles.Add(this.TrimGitIndexLineWithSkipWorktree(line)); - } - - pathData.GitFilePaths.Add(this.TrimGitIndexLineWithSkipWorktree(line)); - }); - GitProcess.Result folderResult = gitProcess.LsTree( - GVFSConstants.DotGit.HeadName, - line => - { - pathData.GitFolderPaths.Add(this.TrimGitIndexLine(line)); - }, - recursive: true, - showDirectories: true); - - pathData.GitTrackingPaths.AddRange(skipWorktreeFiles); - } - } -} diff --git a/GVFS/GVFS/GVFS.Windows.csproj b/GVFS/GVFS/GVFS.Windows.csproj index f9fa1b27d6..8dbcd9bfe9 100644 --- a/GVFS/GVFS/GVFS.Windows.csproj +++ b/GVFS/GVFS/GVFS.Windows.csproj @@ -111,7 +111,6 @@ - diff --git a/GVFS/GVFS/Program.cs b/GVFS/GVFS/Program.cs index 544265b71f..43447e0612 100644 --- a/GVFS/GVFS/Program.cs +++ b/GVFS/GVFS/Program.cs @@ -26,7 +26,6 @@ public static void Main(string[] args) typeof(PrefetchVerb), typeof(RepairVerb), typeof(ServiceVerb), - typeof(HealthVerb), typeof(StatusVerb), typeof(UnmountVerb), typeof(UpgradeVerb), From ad0e2eb9b0354b7e6ed254967d565d5c2c7d8b84 Mon Sep 17 00:00:00 2001 From: Ben Floyd Date: Thu, 8 Aug 2019 14:16:38 -0400 Subject: [PATCH 2/2] Deleted health references in functional test tools --- .../Tools/GVFSFunctionalTestEnlistment.cs | 5 ----- GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs | 12 ------------ 2 files changed, 17 deletions(-) diff --git a/GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs b/GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs index 36bf19d125..16244e5781 100644 --- a/GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs +++ b/GVFS/GVFS.FunctionalTests/Tools/GVFSFunctionalTestEnlistment.cs @@ -231,11 +231,6 @@ public string Status(string trace = null) return this.gvfsProcess.Status(trace); } - public string Health(string directory = null) - { - return this.gvfsProcess.Health(directory); - } - public bool WaitForBackgroundOperations(int maxWaitMilliseconds = DefaultMaxWaitMSForStatusCheck) { return this.WaitForStatus(maxWaitMilliseconds, ZeroBackgroundOperations).ShouldBeTrue("Background operations failed to complete."); diff --git a/GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs b/GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs index 9b196c0b62..c233919257 100644 --- a/GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs +++ b/GVFS/GVFS.FunctionalTests/Tools/GVFSProcess.cs @@ -146,18 +146,6 @@ public string Status(string trace = null) return this.CallGVFS("status " + this.enlistmentRoot, trace: trace); } - public string Health(string directory = null) - { - if (string.IsNullOrEmpty(directory)) - { - return this.CallGVFS("health \"" + this.enlistmentRoot + '"'); - } - else - { - return this.CallGVFS("health -d \"" + directory + "\" \"" + this.enlistmentRoot + '"'); - } - } - public string CacheServer(string args) { return this.CallGVFS("cache-server " + args + " \"" + this.enlistmentRoot + "\"");