Skip to content
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

fix(bump): Search for version number line by line #568

Merged
merged 3 commits into from
Sep 7, 2022

Conversation

Kurt-von-Laven
Copy link
Contributor

@Kurt-von-Laven Kurt-von-Laven commented Aug 22, 2022

Description

Fixes #498.

Add mypy typing for _bump_with_regex.

Avoid the complexities of multiline regex matching and inconsistencies with the case where no regex is specified. Simplify the implementation by eliminating the need to track an offset into the file. Ensure that the version number will be found even if it is to the left of the portion of the line matching the regex.

Remove lookahead assertion from version_files entry for .pre-commit-config.yaml. Commitizen runs bump on itself to, among other things, manage the version it uses of its own pre-commit hooks. When searching .pre-commit-config.yaml for the version number of Commitizen, we search for "Commitizen," which is in a comment to the right of the version number. Remove the lookahead assertion for "Commitizen," and instead simply consume it when matching now that version_files regexes don't need to exclusively match to the left of the version number.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

The version of Commitizen is bumped as usual in all version_files listed in pyproject.toml.

Steps to Test This Pull Request

  1. Run cz bump.

Additional context

As mentioned in #565, I am encountering some difficulties testing Commitizen locally.

@Kurt-von-Laven Kurt-von-Laven force-pushed the line-by-line branch 2 times, most recently from 514d19a to 38907bc Compare August 22, 2022 10:32
Avoid the complexities of multiline regex matching and inconsistencies
with the case where no regex is specified. Simplify the implementation
by eliminating the need to track an offset into the file. Ensure that
the version number will be found even if it is to the left of the
portion of the line matching the regex.
Commitizen runs bump on itself to, among other things, manage the
version it uses of its own pre-commit hooks. When searching
.pre-commit-config.yaml for the version number of Commitizen, we search
for "Commitizen," which is in a comment to the right of the version
number. Remove the lookahead assertion for "Commitizen," and instead
simply consume it when matching now that version_files regexes don't
need to exclusively match to the left of the version number.
@codecov
Copy link

codecov bot commented Aug 22, 2022

Codecov Report

Base: 98.43% // Head: 98.43% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (7f7a606) compared to base (f093717).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #568      +/-   ##
==========================================
- Coverage   98.43%   98.43%   -0.01%     
==========================================
  Files          39       39              
  Lines        1602     1596       -6     
==========================================
- Hits         1577     1571       -6     
  Misses         25       25              
Flag Coverage Δ
unittests 98.43% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
commitizen/__version__.py 100.00% <100.00%> (ø)
commitizen/bump.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@woile
Copy link
Member

woile commented Aug 22, 2022

LGTM! @Lee-W feel free to merge

@woile woile requested a review from Lee-W August 22, 2022 11:01
@woile woile merged commit 81aecc3 into commitizen-tools:master Sep 7, 2022
@Kurt-von-Laven Kurt-von-Laven deleted the line-by-line branch September 7, 2022 16:47
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.

Version Not Bumped If Regex Right of Version
2 participants