mbarkhau / bumpver

BumpVer: Automatic Versioning
https://github.com/mbarkhau/bumpver
MIT License
199 stars 36 forks source link

whitespace pattern proof of concept #228

Open jgrey4296 opened 11 months ago

jgrey4296 commented 11 months ago

This adds basic support for whitespace patterns by altering how regex's are compiled, no longer escaping + and * symbols. To handle this when rewriting lines, a replacement_pattern is added to Pattern, allowing a pre-formatted version string to be subbed into the matching line directly. This means no changes are made to _format_segment.

A couple of tests are added to show it working, and test_v1_error_bad_pattern breaks... but I have no idea why because I didn't touch v1 pattern code.

mbarkhau commented 6 months ago

HI @jgrey4296,

sorry I didn't take the time to review this earlier. In principle I think this is going in the right direction, but we need to make sure to not break any existing configurations.

I would suggest that we introduce a config variable auto_escape = true, where the default is true and if you want to include regex syntax in your version pattern, you need to set it to auto_escape = false.

It might then be appropriate, to skip all of RE_PATTERN_ESCAPES, and not just the ones you commented out.

What do you think?

jgrey4296 commented 6 months ago

no worries, and yeah that makes sense. I'll get on that :)