Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,10 @@ private void ValidateSubDirectoryHealth(List<string> outputLines, List<string> s

private void ValidateEnlistmentStatus(string outputLine, string statusMessage)
{
// Regex to extract the status message for the enlistment
// "Repository status: <status-message>"
Match lineMatch = Regex.Match(outputLine, @"^Repository status:\s*(.*)$");
// Regex to extract the status message for the enlistment. The verb prints
// "Repository status: <status-message>" when the calculation covers the whole enlistment,
// and "Directory status (<path>): <status-message>" when scoped to a subdirectory.
Match lineMatch = Regex.Match(outputLine, @"^(?:Repository status|Directory status \([^)]*\)):\s*(.*)$");

string outputtedStatusMessage = lineMatch.Groups[1].Value;

Expand Down
18 changes: 17 additions & 1 deletion GVFS/GVFS/CommandLine/HealthVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,23 @@ private void PrintOutput(EnlistmentHealthData enlistmentHealthData)

bool healthyRepo = (enlistmentHealthData.PlaceholderPercentage + enlistmentHealthData.ModifiedPathsPercentage) < MaximumHealthyHydration;

this.Output.WriteLine("\nRepository status: " + (healthyRepo ? "OK" : "Highly Hydrated"));
// Only label the summary as "Repository status" when the calculation actually covered
// the whole enlistment. When the user scoped the check to a subdirectory (via -d or by
// running from a subdirectory of the enlistment) the number describes only that subtree,
// so label it accordingly to avoid falsely reporting the repository as highly hydrated.
bool isWholeRepo = string.IsNullOrEmpty(enlistmentHealthData.TargetDirectory)
|| enlistmentHealthData.TargetDirectory == GVFSConstants.GitPathSeparatorString;

string statusLabel = isWholeRepo
? "Repository status"
: "Directory status (" + enlistmentHealthData.TargetDirectory.TrimEnd(GVFSConstants.GitPathSeparator) + ")";

this.Output.WriteLine("\n" + statusLabel + ": " + (healthyRepo ? "OK" : "Highly Hydrated"));

if (!isWholeRepo)
{
this.Output.WriteLine("To see the full repository status, switch to the root of the repository and re-run 'gvfs health'.");
}
}

/// <summary>
Expand Down
Loading