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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static (HashSet<string> bundleProductIds, string entryRepo, bool hideLin
var bundleProductIds = context.EntryToBundleProducts.GetValueOrDefault(entry, new HashSet<string>(StringComparer.OrdinalIgnoreCase));
var entryRepo = context.EntryToRepo.GetValueOrDefault(entry, context.Repo);
var hideLinks = context.EntryToHideLinks.GetValueOrDefault(entry, false);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide, context);
return (bundleProductIds, entryRepo, hideLinks, shouldHide);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 Elastic.Changelog.Configuration;
using Elastic.Documentation;

namespace Elastic.Changelog.Rendering;
Expand All @@ -21,4 +22,5 @@ public record ChangelogRenderContext
public required Dictionary<ChangelogEntry, HashSet<string>> EntryToBundleProducts { get; init; }
public required Dictionary<ChangelogEntry, string> EntryToRepo { get; init; }
public required Dictionary<ChangelogEntry, bool> EntryToHideLinks { get; init; }
public ChangelogConfiguration? Configuration { get; init; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 Elastic.Changelog.Configuration;
using Elastic.Documentation;

namespace Elastic.Changelog.Rendering;
Expand All @@ -23,10 +24,47 @@ public static string GetComponent(ChangelogEntry entry)
}

/// <summary>
/// Determines if an entry should be hidden based on feature IDs
/// Determines if an entry should be hidden based on feature IDs or block configuration
/// </summary>
public static bool ShouldHideEntry(
ChangelogEntry entry,
HashSet<string> featureIdsToHide) =>
!string.IsNullOrWhiteSpace(entry.FeatureId) && featureIdsToHide.Contains(entry.FeatureId);
HashSet<string> featureIdsToHide,
ChangelogRenderContext? context = null)
{
// Check feature IDs first
if (!string.IsNullOrWhiteSpace(entry.FeatureId) && featureIdsToHide.Contains(entry.FeatureId))
return true;

// Check block configuration if context and configuration are available
if (context?.Configuration?.Block == null)
return false;

// Get product IDs for this entry
var productIds = context.EntryToBundleProducts.GetValueOrDefault(entry, new HashSet<string>(StringComparer.OrdinalIgnoreCase));
if (productIds.Count == 0)
return false;

// Check each product's block configuration
foreach (var productId in productIds)
{
var blocker = GetPublishBlockerForProduct(context.Configuration.Block, productId);
if (blocker != null && blocker.ShouldBlock(entry))
return true;
}

return false;
}

/// <summary>
/// Gets the publish blocker configuration for a specific product, checking product-specific overrides first
/// </summary>
private static PublishBlocker? GetPublishBlockerForProduct(BlockConfiguration blockConfig, string productId)
{
// Check product-specific override first
if (blockConfig.ByProduct?.TryGetValue(productId, out var productBlockers) == true)
return productBlockers.Publish;

// Fall back to global publish blocker
return blockConfig.Publish;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Cancel ctx
return false;

// Build render context
var context = BuildRenderContext(input, outputSetup, resolvedResult, featureHidingResult.FeatureIdsToHide);
var context = BuildRenderContext(input, outputSetup, resolvedResult, featureHidingResult.FeatureIdsToHide, config);

// Render output
var renderer = new ChangelogRenderer(_fileSystem, _logger);
Expand Down Expand Up @@ -234,7 +234,8 @@ private static ChangelogRenderContext BuildRenderContext(
RenderChangelogsArguments input,
OutputSetup outputSetup,
ResolvedEntriesResult resolved,
HashSet<string> featureIdsToHide)
HashSet<string> featureIdsToHide,
ChangelogConfiguration? config)
{
// Group entries by type
var entriesByType = resolved.Entries
Expand Down Expand Up @@ -269,7 +270,8 @@ private static ChangelogRenderContext BuildRenderContext(
FeatureIdsToHide = featureIdsToHide,
EntryToBundleProducts = entryToBundleProducts,
EntryToRepo = entryToRepo,
EntryToHideLinks = entryToHideLinks
EntryToHideLinks = entryToHideLinks,
Configuration = config
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override async Task RenderAsync(ChangelogRenderContext context, Cancel ct
foreach (var entry in group)
{
var (bundleProductIds, entryRepo, entryHideLinks) = GetEntryContext(entry, context);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide, context);

_ = sb.AppendLine();
if (shouldHide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override async Task RenderAsync(ChangelogRenderContext context, Cancel ct
foreach (var entry in areaGroup)
{
var (bundleProductIds, entryRepo, entryHideLinks) = GetEntryContext(entry, context);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide, context);

_ = sb.AppendLine();
if (shouldHide)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static void RenderEntriesByArea(
foreach (var entry in areaGroup)
{
var (bundleProductIds, entryRepo, entryHideLinks) = GetEntryContext(entry, context);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide, context);

if (shouldHide)
_ = sb.Append("% ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override async Task RenderAsync(ChangelogRenderContext context, Cancel ct
foreach (var entry in areaGroup)
{
var (bundleProductIds, entryRepo, entryHideLinks) = GetEntryContext(entry, context);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide);
var shouldHide = ChangelogRenderUtilities.ShouldHideEntry(entry, context.FeatureIdsToHide, context);

_ = sb.AppendLine();
if (shouldHide)
Expand Down
Loading
Loading