Skip to content

[Changelog] Strip dash from title prefix#3226

Merged
cotti merged 3 commits into
mainfrom
changelog-strip-dashes
May 4, 2026
Merged

[Changelog] Strip dash from title prefix#3226
cotti merged 3 commits into
mainfrom
changelog-strip-dashes

Conversation

@lcawl
Copy link
Copy Markdown
Contributor

@lcawl lcawl commented May 1, 2026

Summary

This PR fixes the docs-builder changelog add command's --strip-title-prefix option (and matching config file option) so that it handles titles like: [Cases] - Enable cases numerical id service. When creating changelogs, the square brackets are stripped but the hyphen remained and was ultimately renadered as a bullet point.

Screenshots

Before:

prs:
- https://github.com/elastic/kibana/pull/238555
...
title: '- Enable cases numerical id service'
Image

After:

prs:
- https://github.com/elastic/kibana/pull/238555
...
title: Enable cases numerical id service

AI implementation details

Layer 1 — StripSquareBracketPrefix (ChangelogTextUtilities.cs)

  • Tracks whether any [...] prefix was removed.
  • After the existing colon handling, if so, removes one ASCII - when the next character is whitespace (e.g. [Cases] - Enable …Enable …).
  • Leaves titles like - No brackets unchanged (no bracket strip).
  • Leaves [Team]-NoSpace as -NoSpace (no space after -, so the separator rule does not run).

Layer 2 — Defensive YAML (ReleaseNotesSerialization.cs)

  • SerializeEntry runs ApplyDefensiveTitleQuotingIfNeeded after YamlDotNet serialization.
  • New helpers: TitleNeedsDefensiveYamlQuoting in ChangelogTextUtilities.cs for -, *, +, en dash, em dash.
  • If the title needs quoting but the title: line is unquoted, it is rewritten with a double-quoted scalar (ToYamlDoubleQuotedString). If YamlDotNet already used ' or ", the YAML is left as-is.

Tests

Docs & config

dotnet format was applied to ChangelogTextUtilities.cs. Targeted tests in Elastic.Documentation.Configuration.Tests and Elastic.Changelog.Tests pass.

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: composer-2, claude-4-sonnet-thinking

@lcawl lcawl marked this pull request as ready for review May 1, 2026 16:26
@lcawl lcawl requested review from a team as code owners May 1, 2026 16:26
@lcawl lcawl requested a review from cotti May 1, 2026 16:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 1, 2026

Warning

Rate limit exceeded

@lcawl has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 44 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0df5da5d-32d0-42fa-9562-d35e1ea85611

📥 Commits

Reviewing files that changed from the base of the PR and between 38ce9db and fdbf3b0.

📒 Files selected for processing (2)
  • src/Elastic.Documentation.Configuration/ReleaseNotes/ReleaseNotesSerialization.cs
  • tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/ReleaseNotesSerializationTests.cs
📝 Walkthrough

Walkthrough

This PR expands and clarifies title-prefix stripping: --strip-title-prefix now applies to PRs and issues, removes leading bracketed prefixes (multiple) and will also drop a single ASCII hyphen separator when it directly follows a stripped prefix and is followed by whitespace. Serialization now defensively quotes titles that begin with list-marker-like characters (-, *, +, en dash, em dash). Documentation across CLI and configuration files was updated and unit tests added to cover the new stripping and quoting behavior.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant EvalService as ChangelogEvaluationService
    participant TextUtil as ChangelogTextUtilities
    participant Serializer as ReleaseNotesSerialization
    participant YAML as YAML_Output

    User->>CLI: provide PR/issue title (with [prefix] - separator)
    CLI->>EvalService: EvaluatePr / extract title
    EvalService->>TextUtil: StripSquareBracketPrefix(title)
    TextUtil-->>EvalService: strippedTitle (+ flag whether prefix removed)
    EvalService->>TextUtil: TitleNeedsDefensiveYamlQuoting(strippedTitle)
    TextUtil-->>EvalService: needsQuoting (true/false)
    EvalService->>Serializer: SerializeEntry(dto with strippedTitle)
    Serializer->>Serializer: YamlSerializer.Serialize(dto)
    alt needsQuoting == true
        Serializer->>Serializer: ApplyDefensiveTitleQuotingIfNeeded(serializedYaml, title)
    end
    Serializer-->>YAML: final YAML output (title possibly quoted)
    YAML-->>User: emitted changelog/release-notes YAML
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the main change: adding dash-stripping capability to the title prefix option for changelog generation.
Description check ✅ Passed The description comprehensively explains the fix, provides before/after screenshots, details implementation across multiple layers, lists test coverage, and discloses GenAI usage.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch changelog-strip-dashes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 48 minutes and 44 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously requested changes May 1, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/contribute/configure-changelogs-ref.md`:
- Line 125: The markdown line currently uses a code span that includes a
trailing space (the problematic snippet showing a hyphen plus space inside
backticks); update the sentence to avoid a code span with a trailing space by
putting only the hyphen inside the code span and describing the following space
in plain text (e.g., "hyphen" in code, then the word "followed by a space") or
rephrase the sentence to use a quoted or plain-text representation of the
hyphen-plus-space, ensuring MD038 is no longer triggered.

In
`@src/Elastic.Documentation.Configuration/ReleaseNotes/ReleaseNotesSerialization.cs`:
- Around line 114-123: The current rewrite of an unquoted title (in
ReleaseNotesSerialization.cs) blindly replaces the "title:" header without
guarding against YAML block scalars, which corrupts multi-line values; modify
the logic where valuePart is computed (variable valuePart and the branch that
calls ToYamlDoubleQuotedString(title!)) to detect block-style indicators (e.g.,
valuePart starts with '|' or '>': possibly followed by modifiers) and skip
rewriting in that case (return the original yaml or leave lines unchanged) so
continuation lines for a block scalar are preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5ec29846-df02-4b03-bf31-60c49bbad899

📥 Commits

Reviewing files that changed from the base of the PR and between a3b9491 and 167a68f.

📒 Files selected for processing (11)
  • docs/cli/changelog/add.md
  • docs/cli/changelog/evaluate-pr.md
  • docs/cli/changelog/gh-release.md
  • docs/contribute/configure-changelogs-ref.md
  • src/Elastic.Documentation.Configuration/Changelog/ExtractConfiguration.cs
  • src/Elastic.Documentation.Configuration/ReleaseNotes/ReleaseNotesSerialization.cs
  • src/Elastic.Documentation/ReleaseNotes/ChangelogTextUtilities.cs
  • tests/Elastic.Changelog.Tests/Changelogs/Create/TitleProcessingTests.cs
  • tests/Elastic.Changelog.Tests/Evaluation/ChangelogPrEvaluationServiceTests.cs
  • tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/ChangelogTextUtilitiesTests.cs
  • tests/Elastic.Documentation.Configuration.Tests/ReleaseNotes/ReleaseNotesSerializationTests.cs

Comment thread docs/contribute/configure-changelogs-ref.md Outdated
lcawl and others added 2 commits May 1, 2026 14:36
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@cotti cotti merged commit 25c5de5 into main May 4, 2026
24 checks passed
@cotti cotti deleted the changelog-strip-dashes branch May 4, 2026 14:44
Mpdreamz pushed a commit that referenced this pull request May 11, 2026
* [Changelog] Strip dash from title prefix

* Update docs/contribute/configure-changelogs-ref.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Address code feedback

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants