Skip to content

Assembler match: print each content source explicitly #1286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
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
4 changes: 4 additions & 0 deletions actions/assembler-match/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ outputs:
description: 'true/false indicating the branch matches a content-source'
content-source-name:
description: "The name of the content source that matches (current/next) or empty"
content-source-next:
description: "true/false indicating the branch acts as the next content source"
content-source-current:
description: "true/false indicating the branch acts as the current content source"

runs:
using: 'docker'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,29 @@ private static TRepository RepositoryDefaults<TRepository>(TRepository r, string

/// Returns whether the <paramref name="branchOrTag"/> is configured as an integration branch or tag for the given
/// <paramref name="repository"/>.
public ContentSource? Match(string repository, string branchOrTag)
public ContentSourceMatch Match(string repository, string branchOrTag)
{
var repositoryName = repository.Split('/').Last();
var match = new ContentSourceMatch(null, null);
if (ReferenceRepositories.TryGetValue(repositoryName, out var r))
{
if (r.GetBranch(ContentSource.Current) == branchOrTag)
return ContentSource.Current;
match = match with { Current = ContentSource.Current };
if (r.GetBranch(ContentSource.Next) == branchOrTag)
return ContentSource.Next;
return null;
match = match with { Next = ContentSource.Next };
return match;
}

if (repositoryName == NarrativeRepository.RepositoryName)
{
if (Narrative.GetBranch(ContentSource.Current) == branchOrTag)
return ContentSource.Current;
if (Narrative.GetBranch(ContentSource.Next) == branchOrTag)
return ContentSource.Next;
}
if (repositoryName != NarrativeRepository.RepositoryName)
return match;

return null;
if (Narrative.GetBranch(ContentSource.Current) == branchOrTag)
match = match with { Current = ContentSource.Current };
if (Narrative.GetBranch(ContentSource.Next) == branchOrTag)
match = match with { Next = ContentSource.Next };

return match;
}

public record ContentSourceMatch(ContentSource? Current, ContentSource? Next);
}
13 changes: 10 additions & 3 deletions src/tooling/docs-assembler/Cli/ContentSourceCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,25 @@ public async Task<int> Match([Argument] string? repository = null, [Argument] st
AllowIndexing = false
};
var matches = assembleContext.Configuration.Match(repo, refName);
if (matches == null)
if (matches is { Current: null, Next: null })
{
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", repo, refName, name);
if (matches.Current is { } current)
logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, current.ToStringFast(true));
if (matches.Next is { } next)
logger.LogInformation("'{Repository}' '{BranchOrTag}' is configured as '{Matches}' content-source", repo, refName, next.ToStringFast(true));

await githubActionsService.SetOutputAsync("content-source-match", "true");
await githubActionsService.SetOutputAsync("content-source-next", matches.Next is not null ? "true" : "false");
await githubActionsService.SetOutputAsync("content-source-current", matches.Current is not null ? "true" : "false");

//TODO remove once we've merged our changes to the github action and its workflow usage to no longer use this output
var name = (matches.Current ?? matches.Next)!.Value.ToStringFast(true);
await githubActionsService.SetOutputAsync("content-source-name", name);
}

Expand Down
Loading