c4urself / bump2version

Version-bump your software with a single command
https://pypi.python.org/pypi/bump2version
MIT License
1.05k stars 134 forks source link

Add support for leading spaces in search pattern #199

Open sanderr opened 3 years ago

sanderr commented 3 years ago

Leading spaces are currently trimmed from the search pattern. I believe this is inherent in the library used to parse the config file. Since this effectively makes bumpversion unusable for any projects that need a search pattern with leading spaces, I think it would be valuable to add space (and potentially tab) to the special character context so it can be used similarly to {#}.

florisla commented 3 years ago

I think this makes sense. Where did you find out about {#}? I was not familiar with that.

sanderr commented 3 years ago

I found out about it by digging into the code when I was trying to find out the strange behavior that resulted in #198. See here.

florisla commented 3 years ago

We should document this in the README too.

What keywords do we use for space and tab? Simply {space} and {tab}?

sanderr commented 3 years ago

I agree documenting this would be a good idea. I believe there were some other things I didn't find in the README but I didn't think to write them down. I'll create another ticket if it comes to mind.

I like {space} and {tab}, I think they clearly convey the intention.

jaap3 commented 3 years ago

I was trying to achieve the same thing. I'm using bumpversion to bump the version in a package(-lock).json and both the search and replace patterns need to be prefixed by two spaces (and include newlines). Limited (and undocumented) special character handling was added in PR #135, it would be nice if this was expanded to include whitespace characters.

hukkin commented 3 years ago

I think just like https://github.com/c4urself/bump2version/pull/221 this would most conveniently be fixed by allowing configuration in a .bumpversion.toml file, as TOML allows strings with leading and trailing whitespace.

florisla commented 2 years ago

TOML support is discussed in #42. But I think this approach is simpler, and thus could end up being release sooner too.

kdeldycke commented 1 year ago

This issue has been solved by bump-my-version thanks to its transition to TOML-based configuration files.