Skip to content

Fix release formatting to support Major/Minor/Patch changes#6

Merged
konard merged 6 commits intomainfrom
issue-5-00a06dc29d4a
Dec 17, 2025
Merged

Fix release formatting to support Major/Minor/Patch changes#6
konard merged 6 commits intomainfrom
issue-5-00a06dc29d4a

Conversation

@konard
Copy link
Member

@konard konard commented Dec 17, 2025

Summary

Fixes #5 - Resolves two bugs in GitHub release formatting:

  1. Removes incorrect section headers ("### Minor Changes", "### Major Changes", "### Patch Changes") from release notes
  2. Enables PR detection for all release types (Major, Minor, Patch)

Problem

The scripts/format-release-notes.mjs script only handled ### Patch Changes sections, causing it to fail on Minor and Major releases:

  • ❌ Section headers remained in release notes
  • ❌ PR detection was skipped
  • ❌ Release formatting failed silently

Root Cause

The script at scripts/format-release-notes.mjs (lines 92-115) only matched ### Patch Changes:

// Old code - only matched Patch changes
const patchChangesMatchWithHash = currentBody.match(
  /### Patch Changes\s*\n\s*-\s+([a-f0-9]+):\s+(.+?)$/s
);

When a Minor or Major release was created:

  1. The regex pattern failed to match
  2. The script exited early with "⚠️ Could not parse patch changes"
  3. The section header remained in the release notes
  4. PR detection was skipped entirely

Solution

Updated the regex to match all changeset types:

// New code - matches Major, Minor, and Patch changes
const changesPattern =
  /### (Major|Minor|Patch) Changes\s*\n\s*-\s+(?:([a-f0-9]+):\s+)?(.+?)$/s;

Changes Made

Modified Files:

  • scripts/format-release-notes.mjs - Fixed regex pattern to handle all changeset types and updated PACKAGE_NAME constant

Testing:

  • experiments/test-regex-pattern.mjs - Comprehensive test script verifying the regex pattern handles all formats correctly

Implementation Details

The fix:

  1. Updated regex pattern to match ### (Major|Minor|Patch) Changes instead of just ### Patch Changes
  2. Extracts the change type (Major/Minor/Patch) from the match
  3. Handles both formats: with commit hash (- abc1234: Description) and without (- Description)
  4. Updated PACKAGE_NAME constant to gh-download-pull-request to match package.json
  5. Added comprehensive test script to verify the fix works correctly

Testing

  • ✅ All 5 test cases pass in experiments/test-regex-pattern.mjs
  • ✅ Lint checks pass (npm run lint)
  • ✅ Format checks pass (npm run format:check)
  • ✅ File size checks pass (npm run check:file-size)

Expected Behavior After Fix

Release notes will now display cleanly for all release types:

Add new feature description
- Detailed description of changes
...

**Related Pull Request:** #123

---

[![npm version](https://img.shields.io/badge/npm-0.3.0-blue.svg)](https://www.npmjs.com/package/gh-download-pull-request/v/0.3.0)

✅ No section headers
✅ PR link included (when available)
✅ Clean formatting

Reference

This bug was discovered and fixed in the upstream template repository:


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #5
@konard konard self-assigned this Dec 17, 2025
konard and others added 2 commits December 17, 2025 05:14
This commit fixes two bugs in the GitHub release formatting:

1. **Remove section headers**: The script now removes "### Major Changes",
   "### Minor Changes", and "### Patch Changes" headers from release notes.
   Previously, it only handled Patch changes, causing Minor and Major
   releases to display these headers incorrectly.

2. **Enable PR detection for all release types**: By fixing the regex to
   match all changeset types (Major/Minor/Patch), PR detection now works
   for all releases, not just patch releases.

Root Cause:
- The original regex pattern only matched "### Patch Changes"
- When a Minor or Major release was created, the regex failed to match
- The script exited early, skipping formatting and PR link detection
- This resulted in raw changeset headers appearing in release notes

Solution:
- Updated regex to match any changeset type: /### (Major|Minor|Patch) Changes/
- Extract commit hash from any changeset format
- Continue with formatting and PR detection for all release types
- Updated PACKAGE_NAME constant to match package.json

Fixes #5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added a comprehensive test script to verify the regex pattern correctly
handles all changeset types (Major, Minor, Patch) with and without commit
hashes. This helps ensure the fix works as expected and provides a
reusable test for future validation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Release formatting script only handles Patch changes, not Minor/Major Fix release formatting to support Major/Minor/Patch changes Dec 17, 2025
konard and others added 2 commits December 17, 2025 05:16
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard marked this pull request as ready for review December 17, 2025 04:20
@konard
Copy link
Member Author

konard commented Dec 17, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.930190 USD
  • Calculated by Anthropic: $1.006559 USD
  • Difference: $-0.923630 (-47.85%)
    📎 Log file uploaded as GitHub Gist (426KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit a87e5dc into main Dec 17, 2025
14 checks passed
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.

Release formatting script only handles Patch changes, not Minor/Major

1 participant