From 5f92101f823b7b84c4d49c9771a430a31af5fc1d Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Mon, 26 May 2025 13:30:00 +0200 Subject: [PATCH 1/7] Also write the used link-index to the filesystem and add it as part of the new CheckoutResult record --- .../docs-assembler/Cli/RepositoryCommands.cs | 14 +++++++- .../Sourcing/RepositorySourcesFetcher.cs | 35 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs index f23d2f71b..78420f220 100644 --- a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs +++ b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs @@ -18,6 +18,7 @@ using Documentation.Assembler.Navigation; using Documentation.Assembler.Sourcing; using Elastic.Documentation.Configuration.Assembler; +using Elastic.Documentation.Links; using Elastic.Documentation.Tooling.Diagnostics.Console; using Elastic.Markdown; using Elastic.Markdown.Exporters; @@ -106,7 +107,9 @@ public async Task BuildAll( } var cloner = new AssemblerRepositorySourcer(logger, assembleContext); - var checkouts = cloner.GetAll().ToArray(); + var checkoutResult = cloner.GetAll(); + var checkouts = checkoutResult.Checkouts.ToArray(); + if (checkouts.Length == 0) throw new Exception("No checkouts found"); @@ -123,6 +126,15 @@ public async Task BuildAll( var builder = new AssemblerBuilder(logger, assembleContext, navigation, htmlWriter, pathProvider, historyMapper); await builder.BuildAllAsync(assembleSources.AssembleSets, ctx); + if (checkoutResult.LinkRegistrySnapshot is { } linkRegistry) + { + await File.WriteAllTextAsync( + Path.Combine(assembleContext.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), + LinkRegistry.Serialize(linkRegistry), + ctx + ); + } + var sitemapBuilder = new SitemapBuilder(navigation.NavigationItems, assembleContext.WriteFileSystem, assembleContext.OutputDirectory); sitemapBuilder.Generate(); diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index 0ea5adc66..618606f73 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -9,6 +9,7 @@ using Elastic.Documentation.Configuration.Assembler; using Elastic.Documentation.Diagnostics; using Elastic.Documentation.LinkIndex; +using Elastic.Documentation.Links; using Elastic.Markdown.IO; using Microsoft.Extensions.Logging; using ProcNet; @@ -25,7 +26,7 @@ public class AssemblerRepositorySourcer(ILoggerFactory logger, AssembleContext c private RepositorySourcer RepositorySourcer => new(logger, context.CheckoutDirectory, context.ReadFileSystem, context.Collector); - public IReadOnlyCollection GetAll() + public CheckoutResult GetAll() { var fs = context.ReadFileSystem; var repositories = Configuration.ReferenceRepositories.Values.Concat([Configuration.Narrative]); @@ -43,11 +44,19 @@ public IReadOnlyCollection GetAll() }; checkouts.Add(checkout); } - - return checkouts; + var linkRegistrySnapshotPath = Path.Combine(context.CheckoutDirectory.FullName, CheckoutResult.LinkRegistrySnapshotFileName); + if (!fs.File.Exists(linkRegistrySnapshotPath)) + throw new FileNotFoundException("Link-index snapshot not found. Run the clone-all command first.", linkRegistrySnapshotPath); + var linkRegistrySnapshotStr = File.ReadAllText(linkRegistrySnapshotPath); + var linkRegistry = LinkRegistry.Deserialize(linkRegistrySnapshotStr); + return new CheckoutResult + { + Checkouts = checkouts, + LinkRegistrySnapshot = linkRegistry + }; } - public async Task> CloneAll(bool fetchLatest, Cancel ctx = default) + public async Task CloneAll(bool fetchLatest, Cancel ctx = default) { _logger.LogInformation("Cloning all repositories for environment {EnvironmentName} using '{ContentSourceStrategy}' content sourcing strategy", PublishEnvironment.Name, @@ -91,7 +100,16 @@ await Task.Run(() => checkouts.Add(RepositorySourcer.CloneRef(repo.Value, gitRef, fetchLatest)); }, c); }).ConfigureAwait(false); - return checkouts; + await File.WriteAllTextAsync( + Path.Combine(context.CheckoutDirectory.FullName, CheckoutResult.LinkRegistrySnapshotFileName), + LinkRegistry.Serialize(linkRegistry), + ctx + ); + return new CheckoutResult + { + Checkouts = checkouts, + LinkRegistrySnapshot = linkRegistry + }; } } @@ -272,3 +290,10 @@ public void Write(Exception e) { } public void Write(ConsoleOut consoleOut) { } } + +public record CheckoutResult +{ + public static string LinkRegistrySnapshotFileName => "link-index.snapshot.json"; + public required LinkRegistry LinkRegistrySnapshot { get; init; } + public required IReadOnlyCollection Checkouts { get; init; } +} From f39834d3d9ffa3edff530748b309d4901ca05642 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 15:07:11 +0200 Subject: [PATCH 2/7] Refactor git operations --- .../Links/LinkRegistry.cs | 1 + .../docs-assembler/Cli/RepositoryCommands.cs | 1 - .../docs-assembler/Sourcing/GitFacade.cs | 96 ++++++++++++++++ .../Sourcing/RepositorySourcesFetcher.cs | 104 +++++------------- 4 files changed, 124 insertions(+), 78 deletions(-) create mode 100644 src/tooling/docs-assembler/Sourcing/GitFacade.cs diff --git a/src/Elastic.Documentation/Links/LinkRegistry.cs b/src/Elastic.Documentation/Links/LinkRegistry.cs index 0ff49235f..55ec7eeda 100644 --- a/src/Elastic.Documentation/Links/LinkRegistry.cs +++ b/src/Elastic.Documentation/Links/LinkRegistry.cs @@ -2,6 +2,7 @@ // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information +using System.Diagnostics.CodeAnalysis; using System.Text.Json; using System.Text.Json.Serialization; using Elastic.Documentation.Serialization; diff --git a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs index 78420f220..d5e504310 100644 --- a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs +++ b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs @@ -105,7 +105,6 @@ public async Task BuildAll( await assembleContext.Collector.StopAsync(ctx); return 1; } - var cloner = new AssemblerRepositorySourcer(logger, assembleContext); var checkoutResult = cloner.GetAll(); var checkouts = checkoutResult.Checkouts.ToArray(); diff --git a/src/tooling/docs-assembler/Sourcing/GitFacade.cs b/src/tooling/docs-assembler/Sourcing/GitFacade.cs new file mode 100644 index 000000000..f64a38888 --- /dev/null +++ b/src/tooling/docs-assembler/Sourcing/GitFacade.cs @@ -0,0 +1,96 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +using System.IO.Abstractions; +using Elastic.Documentation.Diagnostics; +using ProcNet; + +namespace Documentation.Assembler.Sourcing; + + +public interface IGitRepository +{ + void Init(); + string GetCurrentCommit(); + void GitAddOrigin(string origin); + bool IsInitialized(); + void Pull(string branch); + void Fetch(string reference); + void EnableSparseCheckout(string folder); + void DisableSparseCheckout(); + void Checkout(string reference); +} + +// This git repository implementation is optimized for pull and fetching single commits. +// It uses `git pull --depth 1` and `git fetch --depth 1` to minimize the amount of data transferred. +public class SingleCommitOptimizedGitRepository(DiagnosticsCollector collector, IDirectoryInfo workingDirectory) : IGitRepository +{ + public string GetCurrentCommit() => Capture("git", "rev-parse", "HEAD"); + + public void Init() => ExecIn("git", "init"); + public bool IsInitialized() => Directory.Exists(Path.Combine(workingDirectory.FullName, ".git")); + public void Pull(string branch) => ExecIn("git", "pull", "--depth", "1", "--allow-unrelated-histories", "--no-ff", "origin", branch); + public void Fetch(string reference) => ExecIn("git", "fetch", "--no-tags", "--prune", "--no-recurse-submodules", "--depth", "1", "origin", reference); + public void EnableSparseCheckout(string folder) => ExecIn("git", "sparse-checkout", "set", folder); + public void DisableSparseCheckout() => ExecIn("git", "sparse-checkout", "disable"); + public void Checkout(string reference) => ExecIn("git", "checkout", "--force", reference); + + public void GitAddOrigin(string origin) => ExecIn("git", "remote", "add", "origin", origin); + + private void ExecIn(string binary, params string[] args) + { + var arguments = new ExecArguments(binary, args) + { + WorkingDirectory = workingDirectory.FullName, + Environment = new Dictionary + { + // Disable git editor prompts: + // There are cases where `git pull` would prompt for an editor to write a commit message. + // This env variable prevents that. + { "GIT_EDITOR", "true" } + }, + }; + var result = Proc.Exec(arguments); + if (result != 0) + collector.EmitError("", $"Exit code: {result} while executing {binary} {string.Join(" ", args)} in {workingDirectory}"); + } + private string Capture(string binary, params string[] args) + { + // Try 10 times to capture the output of the command, if it fails, we'll throw an exception on the last try + Exception? e = null; + for (var i = 0; i <= 9; i++) + { + try + { + return CaptureOutput(); + } + catch (Exception ex) + { + if (ex is not null) + e = ex; + } + } + + if (e is not null) + collector.EmitError("", "failure capturing stdout", e); + + return string.Empty; + + string CaptureOutput() + { + var arguments = new StartArguments(binary, args) + { + WorkingDirectory = workingDirectory.FullName, + Timeout = TimeSpan.FromSeconds(3), + WaitForExit = TimeSpan.FromSeconds(3), + ConsoleOutWriter = NoopConsoleWriter.Instance + }; + var result = Proc.Start(arguments); + var line = result.ExitCode != 0 + ? throw new Exception($"Exit code is not 0. Received {result.ExitCode} from {binary}: {workingDirectory}") + : result.ConsoleOut.FirstOrDefault()?.Line ?? throw new Exception($"No output captured for {binary}: {workingDirectory}"); + return line; + } + } +} diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index 618606f73..2c33c28d1 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -3,14 +3,11 @@ // See the LICENSE file in the project root for more information using System.Collections.Concurrent; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using Elastic.Documentation.Configuration.Assembler; using Elastic.Documentation.Diagnostics; using Elastic.Documentation.LinkIndex; using Elastic.Documentation.Links; -using Elastic.Markdown.IO; using Microsoft.Extensions.Logging; using ProcNet; using ProcNet.Std; @@ -31,24 +28,29 @@ public CheckoutResult GetAll() var fs = context.ReadFileSystem; var repositories = Configuration.ReferenceRepositories.Values.Concat([Configuration.Narrative]); var checkouts = new List(); + var linkRegistrySnapshotPath = Path.Combine(context.CheckoutDirectory.FullName, CheckoutResult.LinkRegistrySnapshotFileName); + if (!fs.File.Exists(linkRegistrySnapshotPath)) + throw new FileNotFoundException("Link-index snapshot not found. Run the clone-all command first.", linkRegistrySnapshotPath); + var linkRegistrySnapshotStr = File.ReadAllText(linkRegistrySnapshotPath); + var linkRegistry = LinkRegistry.Deserialize(linkRegistrySnapshotStr); foreach (var repo in repositories) { var checkoutFolder = fs.DirectoryInfo.New(Path.Combine(context.CheckoutDirectory.FullName, repo.Name)); + IGitRepository gitFacade = new SingleCommitOptimizedGitRepository(context.Collector, checkoutFolder); + if (!checkoutFolder.Exists) + { + context.Collector.EmitError(checkoutFolder.FullName, $"'{repo.Name}' does not exist in link index checkout directory"); + continue; + } + var head = gitFacade.GetCurrentCommit(); var checkout = new Checkout { Repository = repo, Directory = checkoutFolder, - //TODO read from links.json and ensure we check out exactly that git reference - //+ validate that git reference belongs to the appropriate branch - HeadReference = Guid.NewGuid().ToString("N") + HeadReference = head }; checkouts.Add(checkout); } - var linkRegistrySnapshotPath = Path.Combine(context.CheckoutDirectory.FullName, CheckoutResult.LinkRegistrySnapshotFileName); - if (!fs.File.Exists(linkRegistrySnapshotPath)) - throw new FileNotFoundException("Link-index snapshot not found. Run the clone-all command first.", linkRegistrySnapshotPath); - var linkRegistrySnapshotStr = File.ReadAllText(linkRegistrySnapshotPath); - var linkRegistry = LinkRegistry.Deserialize(linkRegistrySnapshotStr); return new CheckoutResult { Checkouts = checkouts, @@ -126,6 +128,7 @@ public class RepositorySourcer(ILoggerFactory logger, IDirectoryInfo checkoutDir public Checkout CloneRef(Repository repository, string gitRef, bool pull = false, int attempt = 1) { var checkoutFolder = readFileSystem.DirectoryInfo.New(Path.Combine(checkoutDirectory.FullName, repository.Name)); + IGitRepository git = new SingleCommitOptimizedGitRepository(collector, checkoutFolder); if (attempt > 3) { collector.EmitError("", $"Failed to clone repository {repository.Name}@{gitRef} after 3 attempts"); @@ -143,13 +146,13 @@ public Checkout CloneRef(Repository repository, string gitRef, bool pull = false checkoutFolder.Create(); checkoutFolder.Refresh(); } - var isGitInitialized = GitInit(repository, checkoutFolder); + var isGitInitialized = GitInit(git, repository); string? head = null; if (isGitInitialized) { try { - head = Capture(checkoutFolder, "git", "rev-parse", "HEAD"); + head = git.GetCurrentCommit(); } catch (Exception e) { @@ -165,7 +168,7 @@ public Checkout CloneRef(Repository repository, string gitRef, bool pull = false _logger.LogInformation("{RepositoryName}: HEAD already at {GitRef}", repository.Name, gitRef); else { - FetchAndCheckout(repository, gitRef, checkoutFolder); + FetchAndCheckout(git, repository, gitRef); if (!pull) { return new Checkout @@ -177,7 +180,7 @@ public Checkout CloneRef(Repository repository, string gitRef, bool pull = false } try { - ExecIn(checkoutFolder, "git", "pull", "--depth", "1", "--allow-unrelated-histories", "--no-ff", "origin", gitRef); + git.Pull(gitRef); } catch (Exception e) { @@ -201,84 +204,31 @@ public Checkout CloneRef(Repository repository, string gitRef, bool pull = false /// Initializes the git repository if it is not already initialized. /// Returns true if the repository was already initialized. /// - private bool GitInit(Repository repository, IDirectoryInfo checkoutFolder) + private static bool GitInit(IGitRepository git, Repository repository) { - var isGitAlreadyInitialized = Directory.Exists(Path.Combine(checkoutFolder.FullName, ".git")); + var isGitAlreadyInitialized = git.IsInitialized(); if (isGitAlreadyInitialized) return true; - ExecIn(checkoutFolder, "git", "init"); - ExecIn(checkoutFolder, "git", "remote", "add", "origin", repository.Origin); + git.Init(); + git.GitAddOrigin(repository.Origin); return false; } - private void FetchAndCheckout(Repository repository, string gitRef, IDirectoryInfo checkoutFolder) + private static void FetchAndCheckout(IGitRepository git, Repository repository, string gitRef) { - ExecIn(checkoutFolder, "git", "fetch", "--no-tags", "--prune", "--no-recurse-submodules", "--depth", "1", "origin", gitRef); + git.Fetch(gitRef); switch (repository.CheckoutStrategy) { case CheckoutStrategy.Full: - ExecIn(checkoutFolder, "git", "sparse-checkout", "disable"); + git.DisableSparseCheckout(); break; case CheckoutStrategy.Partial: - ExecIn(checkoutFolder, "git", "sparse-checkout", "set", "docs"); + git.EnableSparseCheckout("docs"); break; default: throw new ArgumentOutOfRangeException(nameof(repository), repository.CheckoutStrategy, null); } - ExecIn(checkoutFolder, "git", "checkout", "--force", gitRef); - } - - private void ExecIn(IDirectoryInfo? workingDirectory, string binary, params string[] args) - { - var arguments = new ExecArguments(binary, args) - { - WorkingDirectory = workingDirectory?.FullName - }; - var result = Proc.Exec(arguments); - if (result != 0) - collector.EmitError("", $"Exit code: {result} while executing {binary} {string.Join(" ", args)} in {workingDirectory}"); - } - - // ReSharper disable once UnusedMember.Local - private string Capture(IDirectoryInfo? workingDirectory, string binary, params string[] args) - { - // Try 10 times to capture the output of the command, if it fails, we'll throw an exception on the last try - Exception? e = null; - for (var i = 0; i <= 9; i++) - { - try - { - return CaptureOutput(); - } - catch (Exception ex) - { - if (ex is not null) - e = ex; - } - } - - if (e is not null) - collector.EmitError("", "failure capturing stdout", e); - - - return string.Empty; - - string CaptureOutput() - { - var arguments = new StartArguments(binary, args) - { - WorkingDirectory = workingDirectory?.FullName, - //WaitForStreamReadersTimeout = TimeSpan.FromSeconds(3), - Timeout = TimeSpan.FromSeconds(3), - WaitForExit = TimeSpan.FromSeconds(3), - ConsoleOutWriter = NoopConsoleWriter.Instance - }; - var result = Proc.Start(arguments); - var line = result.ExitCode != 0 - ? throw new Exception($"Exit code is not 0. Received {result.ExitCode} from {binary}: {workingDirectory}") - : result.ConsoleOut.FirstOrDefault()?.Line ?? throw new Exception($"No output captured for {binary}: {workingDirectory}"); - return line; - } + git.Checkout(gitRef); } } From 8ef5f22e0d5a10d68af94e1f567f086a0646698c Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 15:08:33 +0200 Subject: [PATCH 3/7] Fix naming --- src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index 2c33c28d1..5df860324 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -184,7 +184,7 @@ public Checkout CloneRef(Repository repository, string gitRef, bool pull = false } catch (Exception e) { - _logger.LogError(e, "{RepositoryName}: Failed to update {GitRef} from {RelativePath}, falling back to recreating from scratch", + _logger.LogError(e, "{RepositoryName}: Failed to update {GitRef} from {Path}, falling back to recreating from scratch", repository.Name, gitRef, checkoutFolder.FullName); checkoutFolder.Delete(true); checkoutFolder.Refresh(); From 09e1432492da6c08d0e1532b484a50e138ab06f1 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 15:14:14 +0200 Subject: [PATCH 4/7] Refactor writing linkRegistrySnapshot to AssemblerRepositorySourcer method --- src/tooling/docs-assembler/Cli/RepositoryCommands.cs | 9 +-------- .../docs-assembler/Sourcing/RepositorySourcesFetcher.cs | 6 ++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs index d5e504310..75ad2fabe 100644 --- a/src/tooling/docs-assembler/Cli/RepositoryCommands.cs +++ b/src/tooling/docs-assembler/Cli/RepositoryCommands.cs @@ -125,14 +125,7 @@ public async Task BuildAll( var builder = new AssemblerBuilder(logger, assembleContext, navigation, htmlWriter, pathProvider, historyMapper); await builder.BuildAllAsync(assembleSources.AssembleSets, ctx); - if (checkoutResult.LinkRegistrySnapshot is { } linkRegistry) - { - await File.WriteAllTextAsync( - Path.Combine(assembleContext.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), - LinkRegistry.Serialize(linkRegistry), - ctx - ); - } + await cloner.WriteLinkRegistrySnapshot(checkoutResult.LinkRegistrySnapshot, ctx); var sitemapBuilder = new SitemapBuilder(navigation.NavigationItems, assembleContext.WriteFileSystem, assembleContext.OutputDirectory); sitemapBuilder.Generate(); diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index 5df860324..cb40e317b 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -113,6 +113,12 @@ await File.WriteAllTextAsync( LinkRegistrySnapshot = linkRegistry }; } + + public Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await File.WriteAllTextAsync( + Path.Combine(context.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), + LinkRegistry.Serialize(linkRegistrySnapshot), + ctx + ); } From 42a048ba873de7a26cdaad32ce1a7d36be54c0ea Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 15:16:18 +0200 Subject: [PATCH 5/7] Fix method signature --- src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index cb40e317b..fd10cddc1 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -114,7 +114,7 @@ await File.WriteAllTextAsync( }; } - public Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await File.WriteAllTextAsync( + public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await File.WriteAllTextAsync( Path.Combine(context.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), LinkRegistry.Serialize(linkRegistrySnapshot), ctx From 42ad14fc2620bc50361273eae7cff12a36d39412 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 21:36:28 +0200 Subject: [PATCH 6/7] Update src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs Co-authored-by: Martijn Laarman --- src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index fd10cddc1..78185a46c 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -114,7 +114,7 @@ await File.WriteAllTextAsync( }; } - public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await File.WriteAllTextAsync( + public async Task WriteLinkRegistrySnapshot(LinkRegistry linkRegistrySnapshot, Cancel ctx = default) => await context.WriteFileSystem.File.WriteAllTextAsync( Path.Combine(context.OutputDirectory.FullName, "docs", CheckoutResult.LinkRegistrySnapshotFileName), LinkRegistry.Serialize(linkRegistrySnapshot), ctx From 6c2f39d8b6410682fc8988bce98e23bcc6f38b49 Mon Sep 17 00:00:00 2001 From: Jan Calanog Date: Tue, 27 May 2025 21:39:26 +0200 Subject: [PATCH 7/7] Use context's FileSystem --- src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs index 78185a46c..4b3c83a87 100644 --- a/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs +++ b/src/tooling/docs-assembler/Sourcing/RepositorySourcesFetcher.cs @@ -102,7 +102,7 @@ await Task.Run(() => checkouts.Add(RepositorySourcer.CloneRef(repo.Value, gitRef, fetchLatest)); }, c); }).ConfigureAwait(false); - await File.WriteAllTextAsync( + await context.WriteFileSystem.File.WriteAllTextAsync( Path.Combine(context.CheckoutDirectory.FullName, CheckoutResult.LinkRegistrySnapshotFileName), LinkRegistry.Serialize(linkRegistry), ctx