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
16 changes: 8 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions GVFS/GVFS.Common/Enlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
3 changes: 3 additions & 0 deletions GVFS/GVFS.Common/GVFSConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions GVFS/GVFS.Common/GitStatusCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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(
Expand Down Expand Up @@ -67,14 +69,15 @@ public static EnlistmentHydrationSummary CreateSummary(
TotalFolderCount = totalFolderCount,
};
}
catch
catch (Exception e)
{
return new EnlistmentHydrationSummary()
{
HydratedFileCount = -1,
HydratedFolderCount = -1,
TotalFileCount = -1,
TotalFolderCount = -1,
Error = e,
};
}
}
Expand Down
29 changes: 27 additions & 2 deletions GVFS/GVFS.Hooks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions GVFS/GVFS.UnitTests/Common/GitStatusCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
Loading