Add --strip-title-prefix option to changelog add command #2481
+52
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Impetus
In elastic/docs-content#4627 it becomes obvious that a lot of PR titles have prefixes that we've been automatically or manually removing from release notes. We should have an option for cleaning this up when the changelogs are created.
Overview
Added a new
--strip-title-prefixoption to thedocs-builder changelog addcommand that automatically removes square bracket prefixes from PR titles when creating changelogs.Changes Made
1. Core Implementation
ChangelogInput Class
src/services/Elastic.Documentation.Services/Changelog/ChangelogInput.csStripTitlePrefixboolean property to track whether prefix stripping should be appliedChangelogCommand Class
src/tooling/docs-builder/Commands/ChangelogCommand.cs--strip-title-prefixparameter to theCreatemethodChangelogInput.StripTitlePrefixChangelogService Class
src/services/Elastic.Documentation.Services/ChangelogService.csStripSquareBracketPrefix()helper method that:[]StripTitlePrefixproperty is copied when processing multiple PRs2. Functionality
The
--strip-title-prefixoption:--prsoption--titleis not explicitly provided)"[Inference API] Include rerank in supported tasks for IBM watsonx integration""Include rerank in supported tasks for IBM watsonx integration"3. Documentation Updates
Updated
docs/cli/release/changelog-add.mdanddocs/contribute/changelog.md.Usage Example
./docs-builder changelog add \ --prs https://github.com/elastic/kibana/pull/247965 \ --products "kibana 9.3.0" \ --config /path/to/kibana/docs/changelog.yml \ --strip-title-prefixThe PR title is
"[Attack discovery] Improves Attack discovery hallucination detection"but the changelog contains the following information:Technical Details
Implementation Logic
The
StripSquareBracketPrefix()method:[]character starting from position 1]is found, returns the title unchangedEdge Cases Handled
]found)Testing
StartsWith('[')instead ofStartsWith("[", StringComparison.Ordinal)Files Modified
src/services/Elastic.Documentation.Services/Changelog/ChangelogInput.cssrc/tooling/docs-builder/Commands/ChangelogCommand.cssrc/services/Elastic.Documentation.Services/ChangelogService.csdocs/cli/release/changelog-add.mddocs/contribute/changelog.mdBackward Compatibility
This change is fully backward compatible:
falseif not specified--strip-title-prefixGenerative AI disclosure
Tool(s) and model(s) used: composer-1