From 3ba235f227e02527b5090be2397bc49ae587fcc0 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Tue, 20 May 2025 18:59:01 +0200 Subject: [PATCH] Refactor logging and fix variable usage in Match method Reordered logger initialization and improved logging clarity by fixing variable usage for repository and branch/tag inputs. Ensured consistent use of variables when logging and retrieving inputs for enhanced maintainability. Ensure we log the resolve versions not the raw arguments --- .../docs-assembler/Cli/ContentSourceCommands.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs b/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs index 3f8a5e4de..a791e5db0 100644 --- a/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs +++ b/src/tooling/docs-assembler/Cli/ContentSourceCommands.cs @@ -30,10 +30,14 @@ private void AssignOutputLogger() public async Task Match([Argument] string? repository = null, [Argument] string? branchOrTag = null, Cancel ctx = default) { AssignOutputLogger(); + var logger = logFactory.CreateLogger(); + var repo = repository ?? githubActionsService.GetInput("repository"); + var refName = branchOrTag ?? githubActionsService.GetInput("ref_name"); + logger.LogInformation(" Validating '{Repository}' '{BranchOrTag}' ", repo, refName); + if (string.IsNullOrEmpty(repo)) throw new ArgumentNullException(nameof(repository)); - var refName = branchOrTag ?? githubActionsService.GetInput("ref_name"); if (string.IsNullOrEmpty(refName)) throw new ArgumentNullException(nameof(branchOrTag)); @@ -50,18 +54,17 @@ public async Task Match([Argument] string? repository = null, [Argument] st Force = false, AllowIndexing = false }; - var logger = logFactory.CreateLogger(); var matches = assembleContext.Configuration.Match(repo, refName); if (matches == null) { - logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repository, branchOrTag); + logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repo, refName); await githubActionsService.SetOutputAsync("content-source-match", "false"); await githubActionsService.SetOutputAsync("content-source-name", ""); } else { var name = matches.Value.ToStringFast(true); - logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repository, branchOrTag, name); + logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, name); await githubActionsService.SetOutputAsync("content-source-match", "true"); await githubActionsService.SetOutputAsync("content-source-name", name);