Skip to content

Commit 362f9fd

Browse files
authored
Refactor logging and fix variable usage in Match method (#1283)
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
1 parent b937ea8 commit 362f9fd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/tooling/docs-assembler/Cli/ContentSourceCommands.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ private void AssignOutputLogger()
3030
public async Task<int> Match([Argument] string? repository = null, [Argument] string? branchOrTag = null, Cancel ctx = default)
3131
{
3232
AssignOutputLogger();
33+
var logger = logFactory.CreateLogger<ContentSourceCommands>();
34+
3335
var repo = repository ?? githubActionsService.GetInput("repository");
36+
var refName = branchOrTag ?? githubActionsService.GetInput("ref_name");
37+
logger.LogInformation(" Validating '{Repository}' '{BranchOrTag}' ", repo, refName);
38+
3439
if (string.IsNullOrEmpty(repo))
3540
throw new ArgumentNullException(nameof(repository));
36-
var refName = branchOrTag ?? githubActionsService.GetInput("ref_name");
3741
if (string.IsNullOrEmpty(refName))
3842
throw new ArgumentNullException(nameof(branchOrTag));
3943

@@ -50,18 +54,17 @@ public async Task<int> Match([Argument] string? repository = null, [Argument] st
5054
Force = false,
5155
AllowIndexing = false
5256
};
53-
var logger = logFactory.CreateLogger<ContentSourceCommands>();
5457
var matches = assembleContext.Configuration.Match(repo, refName);
5558
if (matches == null)
5659
{
57-
logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repository, branchOrTag);
60+
logger.LogInformation("'{Repository}' '{BranchOrTag}' combination not found in configuration.", repo, refName);
5861
await githubActionsService.SetOutputAsync("content-source-match", "false");
5962
await githubActionsService.SetOutputAsync("content-source-name", "");
6063
}
6164
else
6265
{
6366
var name = matches.Value.ToStringFast(true);
64-
logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repository, branchOrTag, name);
67+
logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, name);
6568

6669
await githubActionsService.SetOutputAsync("content-source-match", "true");
6770
await githubActionsService.SetOutputAsync("content-source-name", name);

0 commit comments

Comments
 (0)