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 using a single-pass algorithm that processes commits in git log order (newest-first)

Matching Strategy

  • Primary: SHA-based matching using "This reverts commit " from the commit/PR body
  • Fallback: Title-based matching when SHA is not available
  • Also detects reverts via body when title doesn't follow standard `Revert "..."" format

PR Preview Integration

  • Changelog preview (generateChangelogWithHighlight) correctly handles revert PRs
  • Uses pr.head.sha from GitHub API for accurate SHA matching
  • Preserves PR 676 fix: returns PR-specific bump type (not aggregated) unless PR is cancelled by revert processing

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 single-pass, order-agnostic algorithm
  • Integrated into generateRawChangelog() and generateChangelogWithHighlight()
  • Added revert pattern to Bug Fixes category in default config
  • Comprehensive tests for all scenarios including PR preview edge cases
  • Consolidated redundant tests (removed 4 duplicate unit tests covered by integration tests)

@github-actions
Copy link
Contributor

github-actions bot commented Dec 27, 2025

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 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

  • Strip commit patterns from changelog entries by @BYK in #674
  • Add support for custom changelog entries from PR descriptions by @szokeasaurusrex in #648
  • And with support for multiple entries by @szokeasaurusrex in #648
    • and nested items
  • Add changelog preview action and CLI command by @BYK in #669

Other

  • (actions) Make release workflow reusable for external repos by @BYK in #672
  • (aws-lambda) Add version templating for layer names by @BYK in #678

Bug Fixes 🐛

Changelog

  • Handle reverts in changelog and version inference by @BYK in #677
  • Use PR-specific bump type in preview by @BYK in #676

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 5 times, most recently from ba9d07b to 90e36a2 Compare December 27, 2025 21:22
BYK added 2 commits December 28, 2025 13:00
…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 9f44b7d to 30a58aa Compare December 28, 2025 10:01
@BYK BYK marked this pull request as ready for review December 28, 2025 10:04
@BYK BYK changed the title fix(changelog): Handle revert commits properly in changelog and version inference fix(changelog): Handle reverts properly in changelog and version inference Dec 28, 2025
@BYK BYK changed the title fix(changelog): Handle reverts properly in changelog and version inference fix(changelog): Handle reverts in changelog and version inference Dec 28, 2025
@BYK BYK force-pushed the byk/fix/revert-behavior branch 3 times, most recently from cecc303 to 50add5c Compare December 28, 2025 20:14
@BYK BYK force-pushed the byk/fix/revert-behavior branch from 50add5c to ddec3b5 Compare December 28, 2025 20:33
@BYK BYK enabled auto-merge (squash) December 28, 2025 20:38
@BYK BYK merged commit 93e9ed7 into master Dec 29, 2025
15 checks passed
@BYK BYK deleted the byk/fix/revert-behavior branch December 29, 2025 08:50
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.

3 participants