diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1b466edda..bc12832b8 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -177,21 +177,21 @@ jobs: - name: Upload functional tests drop if: steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: FunctionalTests_${{ matrix.configuration }} path: artifacts\GVFS.FunctionalTests - name: Upload FastFetch drop if: steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: FastFetch_${{ matrix.configuration }} path: artifacts\FastFetch - name: Upload installers if: steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: Installers_${{ matrix.configuration }} path: artifacts\GVFS.Installers @@ -220,14 +220,14 @@ jobs: - name: Download installers if: steps.skip.outputs.result != 'true' - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: Installers_${{ matrix.configuration }} path: install - name: Download functional tests drop if: steps.skip.outputs.result != 'true' - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v7 with: name: FunctionalTests_${{ matrix.configuration }} path: ft @@ -249,7 +249,7 @@ jobs: - name: Upload installation logs if: always() && steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: InstallationLogs_${{ matrix.configuration }}_${{ matrix.architecture }}-${{ matrix.nr }} path: install\logs @@ -264,14 +264,14 @@ jobs: - name: Upload functional test results if: always() && steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: FunctionalTests_Results_${{ matrix.configuration }}_${{ matrix.architecture }}-${{ matrix.nr }} path: TestResult.xml - name: Upload Git trace2 output if: always() && steps.skip.outputs.result != 'true' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: GitTrace2_${{ matrix.configuration }}_${{ matrix.architecture }}-${{ matrix.nr }} path: C:\temp\git-trace2.log diff --git a/GVFS/GVFS.Common/Enlistment.cs b/GVFS/GVFS.Common/Enlistment.cs index 090a81c9e..9e40b309c 100644 --- a/GVFS/GVFS.Common/Enlistment.cs +++ b/GVFS/GVFS.Common/Enlistment.cs @@ -122,5 +122,18 @@ public bool GetTrustPackIndexesConfig() return trustPackIndexes; } + + public bool GetStatusHydrationConfig() + { + var gitProcess = this.CreateGitProcess(); + + if (gitProcess.TryGetFromConfig(GVFSConstants.GitConfig.ShowHydrationStatus, forceOutsideEnlistment: false, out var valueString) + && bool.TryParse(valueString, out var statusHydrationConfig)) + { + return statusHydrationConfig; + } + + return GVFSConstants.GitConfig.ShowHydrationStatusDefault; + } } } diff --git a/GVFS/GVFS.Common/GVFSConstants.cs b/GVFS/GVFS.Common/GVFSConstants.cs index f2f05fc02..3f3abecc4 100644 --- a/GVFS/GVFS.Common/GVFSConstants.cs +++ b/GVFS/GVFS.Common/GVFSConstants.cs @@ -42,6 +42,9 @@ public static class GitConfig /* Intended to be a temporary config to allow testing of distrusting pack indexes from cache server * before it is enabled by default. */ public const string TrustPackIndexes = GVFSPrefix + "trust-pack-indexes"; + + public const string ShowHydrationStatus = GVFSPrefix + "show-hydration-status"; + public const bool ShowHydrationStatusDefault = false; } public static class LocalGVFSConfig diff --git a/GVFS/GVFS.Common/GitStatusCache.cs b/GVFS/GVFS.Common/GitStatusCache.cs index 717e7aebc..fd4ef90b9 100644 --- a/GVFS/GVFS.Common/GitStatusCache.cs +++ b/GVFS/GVFS.Common/GitStatusCache.cs @@ -52,7 +52,7 @@ public class GitStatusCache : IDisposable private object cacheFileLock = new object(); - internal static bool TEST_EnableHydrationSummary = true; + internal static bool? TEST_EnableHydrationSummaryOverride = null; public GitStatusCache(GVFSContext context, GitStatusCacheConfig config) : this(context, config.BackoffTime) @@ -341,7 +341,8 @@ private void RebuildStatusCacheIfNeeded(bool ignoreBackoff) private void UpdateHydrationSummary() { - if (!TEST_EnableHydrationSummary) + bool enabled = TEST_EnableHydrationSummaryOverride ?? this.context.Enlistment.GetStatusHydrationConfig(); + if (!enabled) { return; } @@ -372,9 +373,10 @@ private void UpdateHydrationSummary() } else { + metadata["Exception"] = hydrationSummary.Error?.ToString(); this.context.Tracer.RelatedWarning( metadata, - $"{nameof(GitStatusCache)}{nameof(RebuildStatusCacheIfNeeded)}: hydration summary could not be calculdated.", + $"{nameof(GitStatusCache)}{nameof(RebuildStatusCacheIfNeeded)}: hydration summary could not be calculated.", Keywords.Telemetry); } } diff --git a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHydrationSummary.cs b/GVFS/GVFS.Common/HealthCalculator/EnlistmentHydrationSummary.cs index 02a32c2f5..600ba91c5 100644 --- a/GVFS/GVFS.Common/HealthCalculator/EnlistmentHydrationSummary.cs +++ b/GVFS/GVFS.Common/HealthCalculator/EnlistmentHydrationSummary.cs @@ -12,6 +12,8 @@ public class EnlistmentHydrationSummary public int TotalFileCount { get; private set; } public int HydratedFolderCount { get; private set; } public int TotalFolderCount { get; private set; } + public Exception Error { get; private set; } = null; + public bool IsValid { @@ -28,12 +30,12 @@ public string ToMessage() { if (!IsValid) { - return "Error calculating hydration. Run 'gvfs health' for details."; + return "Error calculating hydration summary. Run 'gvfs health' at the repository root for hydration status details."; } int fileHydrationPercent = TotalFileCount == 0 ? 0 : (100 * HydratedFileCount) / TotalFileCount; int folderHydrationPercent = TotalFolderCount == 0 ? 0 : ((100 * HydratedFolderCount) / TotalFolderCount); - return $"{fileHydrationPercent}% of files and {folderHydrationPercent}% of folders hydrated. Run 'gvfs health' for details."; + return $"{fileHydrationPercent}% of files and {folderHydrationPercent}% of folders hydrated. Run 'gvfs health' at the repository root for details."; } public static EnlistmentHydrationSummary CreateSummary( @@ -67,7 +69,7 @@ public static EnlistmentHydrationSummary CreateSummary( TotalFolderCount = totalFolderCount, }; } - catch + catch (Exception e) { return new EnlistmentHydrationSummary() { @@ -75,6 +77,7 @@ public static EnlistmentHydrationSummary CreateSummary( HydratedFolderCount = -1, TotalFileCount = -1, TotalFolderCount = -1, + Error = e, }; } } diff --git a/GVFS/GVFS.Hooks/Program.cs b/GVFS/GVFS.Hooks/Program.cs index 0bfe0da54..d48230a2a 100644 --- a/GVFS/GVFS.Hooks/Program.cs +++ b/GVFS/GVFS.Hooks/Program.cs @@ -88,8 +88,9 @@ private static void RunPreCommands(string[] args) ProcessHelper.Run("gvfs", "prefetch --commits", redirectOutput: false); break; case "status": - /* If status is being run to serialize for caching, skip the health display */ - if (!args.Any(arg => arg.StartsWith("--serialize", StringComparison.OrdinalIgnoreCase))) + /* If status is being run to serialize for caching, or if --porcelain is specified, skip the health display */ + if (!ArgsBlockHydrationStatus(args) + && ConfigurationAllowsHydrationStatus()) { /* Display a message about the hydration status of the repo */ ProcessHelper.Run("gvfs", "health --status", redirectOutput: false); @@ -98,6 +99,30 @@ private static void RunPreCommands(string[] args) } } + private static bool ArgsBlockHydrationStatus(string[] args) + { + return args.Any(arg => + arg.StartsWith("--serialize", StringComparison.OrdinalIgnoreCase) + || arg.StartsWith("--porcelain", StringComparison.OrdinalIgnoreCase)); + } + + private static bool ConfigurationAllowsHydrationStatus() + { + try + { + ProcessResult result = ProcessHelper.Run("git", $"config --get {GVFSConstants.GitConfig.ShowHydrationStatus}"); + bool hydrationStatusEnabled; + if (bool.TryParse(result.Output.Trim(), out hydrationStatusEnabled)) + { + return hydrationStatusEnabled; + } + } + catch (Exception) + { + } + return GVFSConstants.GitConfig.ShowHydrationStatusDefault; + } + private static void ExitWithError(params string[] messages) { foreach (string message in messages) diff --git a/GVFS/GVFS.UnitTests/Common/GitStatusCacheTests.cs b/GVFS/GVFS.UnitTests/Common/GitStatusCacheTests.cs index 20ea38171..59737a83f 100644 --- a/GVFS/GVFS.UnitTests/Common/GitStatusCacheTests.cs +++ b/GVFS/GVFS.UnitTests/Common/GitStatusCacheTests.cs @@ -73,7 +73,7 @@ public void SetUp() this.fileSystem, new MockGitRepo(tracer, enlistment, this.fileSystem), enlistment); - GitStatusCache.TEST_EnableHydrationSummary = false; + GitStatusCache.TEST_EnableHydrationSummaryOverride = false; } [TearDown] @@ -85,7 +85,7 @@ public void TearDown() this.gitParentPath = null; this.gvfsMetadataPath = null; this.enlistmentDirectory = null; - GitStatusCache.TEST_EnableHydrationSummary = true; + GitStatusCache.TEST_EnableHydrationSummaryOverride = null; } [TestCase]