Skip to content

Conversation

@BYK
Copy link
Member

@BYK BYK commented Dec 27, 2025

Summary

When generating changelogs or inferring version bumps, revert commits are now handled properly:

  1. Revert cancellation: When both a revert commit and its target are in the current changelog, they cancel each other out (neither appears in the changelog nor affects version bump)

  2. Standalone reverts: When a revert's target is not in the current changelog (e.g., was in a previous release), the revert appears in the Bug Fixes category with a patch version bump

  3. Nested reverts: Chains like `Revert "Revert "..."`` are handled correctly by processing reverts in reverse chronological order

Matching Strategy

  • Primary: SHA-based matching using "This reverts commit " from the commit body
  • Fallback: Title-based matching when SHA is not available

Examples

Scenario Input Result
Simple revert A, Revert A Empty (cancel out)
Double revert A, Revert A, Revert Revert A A remains
Triple revert A, B, C, D (chain) Empty
Quadruple revert A, B, C, D, E (chain) A remains
Standalone revert Revert A (A not in list) Revert in Bug Fixes

Changes

  • Added revert detection utilities (isRevertCommit, extractRevertedSha, extractRevertedTitle)
  • Added processReverts() function with reverse-chronological processing
  • Integrated into generateRawChangelog() and generateChangelogWithHighlight()
  • Added revert pattern to Bug Fixes category in default config
  • Added comprehensive tests for all scenarios

BYK added 5 commits December 27, 2025 12:33
…tries

By default, conventional commit type prefixes (e.g., 'feat(api): ') are now
stripped from changelog entries. The scope is preserved when entries aren't
grouped under a scope header.

This is controlled via named capture groups in commit_patterns:
- (?<type>...) - The prefix to strip
- (?<scope>...) - The scope to preserve when no scope header is shown

Users can disable stripping by using non-capturing groups in their patterns.
Previously, 'Other' header for scopeless entries was only shown when there
were scopes with 2+ entries (getting their own header). This caused confusion
when a single unscoped entry appeared after a scope header, looking like it
was part of that scope.

Now 'Other' header is shown whenever there are any scoped entries, except
when scopeless is the only group (where 'Other' would be meaningless).
When a scope has 2+ entries it gets its own header (e.g., '#### Api').
Single-scope entries and scopeless entries now go under an 'Other'
header to clearly separate them from the grouped scopes.

This prevents confusion where single entries appeared to belong to
the previous scope's header.
- Test that single-scope entries get 'Other' header when scope groups exist
- Test that no 'Other' header when only scopeless entries
- Test that no 'Other' header when all scopes are single-entry
@github-actions
Copy link
Contributor

github-actions bot commented Dec 27, 2025

Suggested Version Bump

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Changelog

Other

  • (actions) Make release workflow reusable for external repos by @BYK in #672

Bug Fixes 🐛

  • (changelog) Handle revert commits properly in changelog and version inference by @BYK in #677

Documentation 📚

  • New documentation site! by @BYK in #668

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 27, 2025

PR Preview Action v1.7.1

🚀 View preview at
https://getsentry.github.io/craft/pr-preview/pr-677/

Built to branch gh-pages at 2025-12-27 21:54 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@BYK BYK force-pushed the byk/fix/revert-behavior branch 4 times, most recently from f1a7804 to ba9d07b Compare December 27, 2025 21:16
…on inference

When generating changelogs or inferring version bumps:
- Revert commits that cancel out their target (both in current changelog) are removed
- Standalone reverts (target not in changelog) appear as bug fixes with patch bump
- Nested reverts (Revert Revert...) are handled by processing in reverse chronological order
- SHA-based matching is preferred, with title matching as fallback
@BYK BYK force-pushed the byk/fix/revert-behavior branch from ba9d07b to 90e36a2 Compare December 27, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants