fix(bump): Search for version number line by line #568
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thatversion_files
regexes don't need to exclusively match to the left of the version number.Checklist
./scripts/format
and./scripts/test
locally to ensure this change passes linter check and testExpected behavior
The version of Commitizen is bumped as usual in all
version_files
listed inpyproject.toml
.Steps to Test This Pull Request
cz bump
.Additional context
As mentioned in #565, I am encountering some difficulties testing Commitizen locally.