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 #1431

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

Conversation

Copy link
Contributor

@bearomorphism bearomorphism commented May 17, 2025
edited
Loading

Closes #129

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

Lee-W reacted with thumbs up emoji
Copy link

codecov bot commented May 17, 2025
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.97%. Comparing base (d968f26) to head (9c3421c).

Additional details and impacted files
@@ Coverage Diff @@
## refactors #1431 +/- ##
=============================================
+ Coverage 97.92% 97.97% +0.04% 
=============================================
 Files 58 59 +1 
 Lines 2704 2770 +66 
=============================================
+ Hits 2648 2714 +66 
 Misses 56 56 
Flag Coverage Δ
unittests 97.97% <100.00%> (+0.04%) ⬆️

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.

@bearomorphism bearomorphism changed the title (削除) refactor(bump_rule): add bump_rule interface, DefaultBumpRule and its... (削除ここまで) (追記) refactor(bump_rule): strict check and reorganize (追記ここまで) May 17, 2025
@bearomorphism bearomorphism marked this pull request as ready for review May 17, 2025 20:26
@bearomorphism bearomorphism changed the title (削除) refactor(bump_rule): strict check and reorganize (削除ここまで) (追記) fix(bump_rule): strict check and reorganize (追記ここまで) May 17, 2025
Comment on lines 94 to 153
self._BREAKING_CHANGE,
"fix",
"feat",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
Copy link
Contributor Author

@bearomorphism bearomorphism May 17, 2025

Choose a reason for hiding this comment

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

This makes the pattern matching more strict.

Comment on lines 31 to 36
# TODO: deprecate these
bump_pattern: str | None = None
bump_map: dict[str, str] | None = None
bump_map_major_version_zero: dict[str, str] | None = None
Copy link
Contributor Author

@bearomorphism bearomorphism May 17, 2025

Choose a reason for hiding this comment

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

Not sure how to address these fields if we decide to check in the bump_rule change.

Comment on lines -44 to -54
if new_increment is None:
logger.debug(
f"no increment needed for '{found_keyword}' in '{message}'"
)

if VERSION_TYPES.index(increment) < VERSION_TYPES.index(new_increment):
logger.debug(
f"increment detected is '{new_increment}' due to '{found_keyword}' in '{message}'"
)
increment = new_increment
Copy link
Contributor Author

@bearomorphism bearomorphism May 17, 2025
edited
Loading

Choose a reason for hiding this comment

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

I don't think we need these logs. The algorithm can be very simple as the current implementation of get_highest_by_messages

@bearomorphism bearomorphism mentioned this pull request May 18, 2025
10 tasks
Copy link
Contributor Author

The tests finally passed...

'MINOR'
"""
return SemVerIncrement.get_highest(
get_increment(line)
Copy link
Contributor Author

@bearomorphism bearomorphism May 19, 2025

Choose a reason for hiding this comment

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

I don't think we need these logs. The algorithm can be very simple as the current implementation of find_increment_by_callable

We can log the traces in get_increment though.

Comment on lines 187 to 246
try:
if ret := SemVerIncrement.get_highest(
(increment for name, increment in bump_map.items() if m.group(name)),
):
return ret
except IndexError:
# Fallback to old school bump rule
pass
Copy link
Contributor Author

@bearomorphism bearomorphism May 19, 2025
edited
Loading

Choose a reason for hiding this comment

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

This addresses the problem mentioned in #129

#129 (comment)

@bearomorphism bearomorphism changed the title (削除) fix(bump_rule): strict check and reorganize (削除ここまで) (追記) fix(bump_rule): add BumpRule, enum SemVerIncrement and Prerelease (追記ここまで) May 19, 2025
Copy link
Contributor Author

Hope the doc string make it easier to review

@bearomorphism bearomorphism changed the title (削除) fix(bump_rule): add BumpRule, enum SemVerIncrement and Prerelease (削除ここまで) (追記) feat(bump_rule): add BumpRule, VersionIncrement, Prerelease Enum (追記ここまで) May 29, 2025
@bearomorphism bearomorphism changed the base branch from master to refactors May 31, 2025 18:11
@github-actions github-actions bot added the type: feature A new enhacement proposal label May 31, 2025
@Lee-W Lee-W added this to the 4.9.0 milestone Jun 8, 2025
@Lee-W Lee-W force-pushed the refactors branch 2 times, most recently from baee83e to a9cd957 Compare June 8, 2025 13:31
@bearomorphism bearomorphism force-pushed the bump-rule-interface branch 2 times, most recently from fc31bee to 4279a25 Compare June 8, 2025 15:42
@bearomorphism bearomorphism force-pushed the bump-rule-interface branch 2 times, most recently from 6e3caa5 to 8c7e2d3 Compare June 8, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@woile woile Awaiting requested review from woile

@Lee-W Lee-W Awaiting requested review from Lee-W

@noirbizarre noirbizarre Awaiting requested review from noirbizarre

Assignees
No one assigned
Projects
None yet
Milestone
4.9.0
Development

Successfully merging this pull request may close these issues.

Use named capture group in bump_pattern to enable stricter check

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