Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(bump_rule): add BumpRule, VersionIncrement, Prerelease Enum #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bearomorphism wants to merge 45 commits into commitizen-tools:master
base: master
Choose a base branch
Loading
from bearomorphism:bump-rule-interface

Conversation

Copy link
Contributor

@bearomorphism bearomorphism commented Jun 9, 2025

Related issue: #129
Original PR: #1431

Description

Please see bump_rule.py, bump.py, cz/base.py, version_scheme.py and commands/bump.py (~350 lines).
The rest 1000+ lines are just tests and renaming.

  • Rewrote the bump pattern matching mechanism to make the algorithm more strict and maintainable.
  • Maintained backward compatibility with CustomBumpRule.
  • (削除) Simplified code. (削除ここまで)
  • Added a new Enum class SemVerIncrement and replace MAJOR, MINOR, PATCH with the Enum.
  • Now Prerelease is Enum.
  • Simplify find_increment logic in SemVerIncrement.get_highest_by_messages.
    • find_increment was the combination of 2 features: "finding the highest semantic version increment" and "parsing the semantic version increment from each git commit message".

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly

Expected Behavior

Steps to Test This Pull Request

Additional Context

Copy link

codecov bot commented Jun 9, 2025
edited
Loading

Codecov Report

❌ Patch coverage is 97.61905% with 8 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v4-9-0-test@75a97e5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
commitizen/commands/init.py 88.05% 8 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@
## v4-9-0-test #1518 +/- ##
==============================================
 Coverage ? 98.35% 
==============================================
 Files ? 59 
 Lines ? 2735 
 Branches ? 0 
==============================================
 Hits ? 2690 
 Misses ? 45 
 Partials ? 0 
Flag Coverage Δ
unittests 98.35% <97.61%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Lee-W Lee-W changed the base branch from master to v4-9-0-test June 10, 2025 02:59
Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely a great pull request that cleans up a lot of legacy code. However, we need to be cautious about maintaining backward compatibility. We can likely add some of the logic incrementally while keeping compatibility for a few minor versions. After that, we can bump the major version and remove the compatibility handling code.



class ConventionalCommitBumpRule(BumpRule):
_BREAKING_CHANGE_TYPES = set(["BREAKING CHANGE", "BREAKING-CHANGE"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_BREAKING_CHANGE_TYPES = set(["BREAKING CHANGE", "BREAKING-CHANGE"])
_BREAKING_CHANGE_TYPES = {"BREAKING CHANGE", "BREAKING-CHANGE"}

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return bump.find_increment(commits, regex=bump_pattern, increments_map=bump_map)
return VersionIncrement.get_highest_by_messages(
(commit.message for commit in commits),
lambda x: self.cz.bump_rule.get_increment(x, is_major_version_zero),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be a breaking change for other non-standard czs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need a way to keep backward compatibility or move it to 5.0.0 instead (but that would be a pity since the PR looks os good)

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide more details about why this might be a breaking change for non-standard cz s? I am not familiar with non-standard cz. Thanks

CHANGELOG_FORMAT = "markdown"

BUMP_PATTERN = r"^((BREAKING[\-\ ]CHANGE|\w+)(\(.+\))?!?):"
BUMP_MAP = OrderedDict(
BUMP_MAP = dict(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we'll be able to remove them in the next major version?

Copy link
Contributor Author

@bearomorphism bearomorphism Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably yes

Copy link
Contributor Author

Can we do squash rebase on this PR when it is ready for merge?

Copy link
Member

Lee-W commented Aug 25, 2025

Can we do squash rebase on this PR when it is ready for merge?

yep, I can do that

timsu92 and others added 14 commits August 30, 2025 12:25
Original "push" stage has been deprecated since pre-commit v3.2.0. See pre-commit/pre-commit#2732 and pre-commit/pre-commit#2808 for detailed information.
@Lee-W Lee-W force-pushed the bump-rule-interface branch from 3cf6689 to 6d0aa11 Compare August 30, 2025 04:29
Copy link
Contributor Author

What are the next steps for this PR? If there are backward compatibility issues, I can adjust it so that this PR can be checked in. Thanks

@Lee-W Lee-W modified the milestones: 4.9.0, 4.10.0 Sep 9, 2025
@Lee-W Lee-W deleted the branch commitizen-tools:master September 9, 2025 06:09
@Lee-W Lee-W closed this Sep 9, 2025
@Lee-W Lee-W reopened this Sep 9, 2025
@Lee-W Lee-W changed the base branch from v4-9-0-test to master September 9, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Lee-W Lee-W Lee-W left review comments

@woile woile Awaiting requested review from woile woile is a code owner

@noirbizarre noirbizarre Awaiting requested review from noirbizarre noirbizarre is a code owner

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
Projects
None yet
Milestone
4.10.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /