Skip to content

Enhance changelog remove command with github release workflow#2844

Open
lcawl wants to merge 6 commits intofeat/changelog-bundle-release-versionfrom
feat/changelog-remove-release-version
Open

Enhance changelog remove command with github release workflow#2844
lcawl wants to merge 6 commits intofeat/changelog-bundle-release-versionfrom
feat/changelog-remove-release-version

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Mar 3, 2026

Summary

This PR builds on #2843 and #2841.
It enhances the docs-builder changelog remove command to also be able to derive a list of PRs from a GitHub release and use that as the filter for which changelogs to remove.
Thus it will be able to do the optional changelog cleanup for users of either the changelog gh-release or changelog add and changelog bundle commands (where they used a GitHub release as input).

Files changed

  1. Commands/ChangelogCommand.cs — Added --release-version and --owner options to the Remove command with the same behavior as bundle --release-version:

    • Fetches the GitHub release via IGitHubReleaseService
    • Parses PR references from the release body using ReleaseNoteParser
    • Converts them to full PR URLs and injects them as the --prs filter, then falls through to the existing removal logic
    • Mutually exclusive with --all, --products, --prs, and --issues
    • Blocked in profile mode with a clear error message
    • Defaults --owner to elastic when not specified
  2. docs/contribute/changelog.md — Added a "Remove by GitHub release" subsection ([changelog-remove-release-version]) with an example command, and updated the filter-options list and authorization note to cover the new option. Also updated docs/cli/release/changelog-remove.md

  3. tests/Elastic.Changelog.Tests/Changelogs/RemoveReleaseVersionTests.cs — 6 new tests covering:

    • Core removal (matched files deleted, unmatched files left alone)
    • Dry-run safety (no files deleted)
    • No PR refs in release notes (parser returns empty → early exit)
    • Release fetch failure (null return)
    • latest tag forwarded to fetch service
    • Partial match (only changelogs for PRs in the release are removed)

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: claude-4.6-sonnet-medium

lcawl added 3 commits March 3, 2026 10:52
The `changelog remove --release-version` option mirrors the equivalent
bundle flag: it fetches the GitHub release, parses PR references from
the release notes, and removes only the changelogs whose PRs appear in
that release.

- Adds --release-version / --repo to the Remove command, with the same
  mutual-exclusivity guards used by the bundle command (cannot be
  combined with --all, --products, --prs, or --issues).
- Profile mode blocks --release-version with a clear error message.
- Adds RemoveReleaseVersionTests (6 tests covering: core removal,
  dry-run safety, no PR refs, fetch failure, "latest" tag, and partial
  match).
- Documents the new option in contribute/changelog.md under a dedicated
  "Remove by GitHub release" section.

Made-with: Cursor
lcawl added 3 commits March 3, 2026 12:55
…-version

Aligns with PR #2791 (bundle.repo/owner config fields) and PR #2808
(owner stored in bundle YAML and used for link generation).

Config model changes:
- BundleConfiguration gains Repo and Owner properties
- BundleConfigurationYaml and ChangelogConfigurationLoader updated to
  serialize/deserialize the new fields

Service changes:
- ChangelogBundlingService.ApplyConfigDefaults falls back to
  config.Bundle.Repo / config.Bundle.Owner when CLI flags are absent
- ChangelogRemoveService.ApplyConfigDefaults does the same

Command changes:
- Both Bundle and Remove --release-version blocks now load the changelog
  config before fetching the GitHub release, so the owner used to
  construct PR URLs follows the full precedence:
    --owner CLI > bundle.owner in changelog.yml > "elastic"
- Same fix applied to the Bundle command for consistency

Docs:
- changelog-remove.md and contribute/changelog.md document the owner
  precedence, restore the "Remove by GitHub release" section, and add
  a matching note to the bundle release-version section

Tests:
- Two new tests in ChangelogRemoveTests verify config owner fallback
  and that explicit --owner overrides the config value

Made-with: Cursor
`--release-version` on both `changelog bundle` and `changelog remove`
now falls back to `bundle.repo` from `changelog.yml` when `--repo` is
not supplied on the command line, matching the existing `--owner`
precedence behaviour.  A repo is still required from one of the two
sources; if neither is present the command fails with an updated error
message.

Docs and tests updated accordingly.

Made-with: Cursor
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.

1 participant