Skip to content

fix: improve semantic versioning regex and history parsing#701

Open
dhairya-pandya wants to merge 2 commits intotattle-made:mainfrom
dhairya-pandya:semantic-versioning
Open

fix: improve semantic versioning regex and history parsing#701
dhairya-pandya wants to merge 2 commits intotattle-made:mainfrom
dhairya-pandya:semantic-versioning

Conversation

@dhairya-pandya
Copy link
Copy Markdown

@dhairya-pandya dhairya-pandya commented Jan 30, 2026

Pull Request concerning to Issue #680

Description

I've updated the semantic versioning script to fix the issue where feat: commits were being incorrectly downgraded to patch bumps.

The main problem was a strict regex that couldn't handle breaking change markers (!) or flexible spacing before the colon. Since the script has a silent fallback to patch whenever the regex fails, these features weren't being caught correctly.

Changes

Updated the commit parser: The regex is now more robust and supports feat!:, standard scopes (), and legacy square bracket scopes [] and even blank spaces.
Explicit Breaking Changes: The script now specifically checks for the ! marker to trigger MAJOR bumps.
Corrected Git Range: Fixed the git log boundary to properly exclude the previous release commit.
Debug Visibility: Added some print statements so we can see exactly how each commit is being parsed in the GitHub Action logs.

Verification

I tested this locally across various commit formats (standard, scoped, breaking) to ensure they all map to the correct semantic version.

Summary by CodeRabbit

  • Bug Fixes

    • Broader and earlier detection of breaking changes (covers hyphenated variants and optional breaking marker)
    • Improved classification of commit types for more accurate version bumps
  • Chores

    • Expanded type coverage (including feature as minor and more patch aliases)
    • Adjusted commit range handling for package processing
    • Added debug logging for release traceability

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Modifies semantic-release parsing and commit range handling: preserves original case while using lowercase variants for detection, expands conventional-commit parsing (breaking marker '!' support, broader BREAKING CHANGE detection), adds more type aliases, changes git range semantics, and adds per-commit debug logging.

Changes

Cohort / File(s) Summary
Semantic Release Versioning Logic
scripts/semantic_release_workflow.py
Refactored _parse_conventional_commit to trim then create a lowercase variant, detect BREAKING CHANGE in footer/body and hyphenated forms, support optional ! breaking marker and flexible spacing, return is_breaking and lowercase type, and expand type_bump_map (adds feature→minor and extra patch aliases). get_package_commits git range changed from prev_commit^..current_commit to prev_commit..current_commit. determine_package_bump includes debug prints for each commit and computed bump.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐰 I nibble commits both big and small,
Spotting "BREAKING" and a tiny ! call.
Types now wiser, ranges set right,
Debug traces hopping into the night,
Version bumps sing in the moonlight 🌙

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: improving the semantic versioning regex pattern and enhancing conventional commit history parsing to properly detect breaking changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

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

Copy link
Copy Markdown

@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: 1

🤖 Fix all issues with AI agents
In `@scripts/semantic_release_workflow.py`:
- Around line 129-134: The current check in semantic_release_workflow.py uses
the variables message and lower_message and only looks for the substring
"breaking change", so "BREAKING-CHANGE" footers are missed; update the logic
that determines a major bump (the if "breaking change" in lower_message branch)
to also detect the hyphenated variant e.g. by matching a pattern like
"breaking[- ]change" against lower_message or by normalizing hyphens to spaces
before the check, ensuring both "breaking change" and "breaking-change" trigger
return "major".
🧹 Nitpick comments (1)
scripts/semantic_release_workflow.py (1)

296-299: Optional: guard debug logging to avoid noisy CI output.

If this runs on every workflow, the per-commit prints can be quite chatty; a simple flag keeps logs lean when not troubleshooting.

♻️ Suggested tweak
-                print(f"DEBUG: {package_path} commit: '{commit}' -> bump: {commit_bump}")
+                if os.getenv("SEMVER_DEBUG") == "1":
+                    print(f"DEBUG: {package_path} commit: '{commit}' -> bump: {commit_bump}")

Checks for breaking-change in the message
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.

1 participant