peritus / bumpversion

Version-bump your software with a single command
https://pypi.python.org/pypi/bumpversion
MIT License
1.5k stars 147 forks source link

bumpversion removes comments from setup.cfg #86

Closed philipsd6 closed 8 years ago

philipsd6 commented 9 years ago
 ❯ cat setup.cfg
[egg_info]
#tag_build = dev

[easy_install]
index_url = http://myserver/pypi

[bumpversion]
current_version = 1.1.3

[bumpversion:file:setup.py]
 ❯ bumpversion patch --allow-dirty
 ❯ cat setup.cfg
[bumpversion]
current_version = 1.1.4

[egg_info]

[easy_install]
index_url = http://myserver/pypi

[bumpversion:file:setup.py]

That comment is used by my CI tool -- on pull requests, it uncomments it to build a dev package. If bumpversion deletes it, it breaks the process.

For now, I'm switching back to using bumpversion.cfg, but I was hoping to consolidate this in setup.cfg

peritus commented 9 years ago

Hmpf, that's unfortunate.

Bumpversion uses ConfigParser to read and write the config files (and appearently that process doesn't support keeping comments where they were before), at least to my knowledge.

I can't promise that bumpversion will ever support that (unless ConfigParser starts supporting this), but it's good that you found the workaround.

inirudebwoy commented 9 years ago

I have looked into this issue a bit. This issue and possibly #78 can be fixed with refactoring out the config part out of main function and swapping ConfigParser with configobj. Working on it.

peritus commented 9 years ago

refactoring out the config part out of main function and swapping ConfigParser with configobj

Would swapping the main dependency (at it's heart bumpversion is just config parsing, not much more) mean it stays backwards compatible ?

peritus commented 9 years ago

Also thanks for pointing me to configobj, I didn't know that library :)

inirudebwoy commented 9 years ago

Would swapping the main dependency (at it's heart bumpversion is just config parsing, not much more) mean it stays backwards compatible ?

Good point, configobj would be perfect but they do not support lists notation used by setup.cfg and bumpversion.cfg. Dependency swap was relatively easy solution as long as the tool supports same features as ConfigParser. So configobj is out.

However config related logic has to be moved and abstracted so in future it is easier to fix any config read/write issues, like this one, and any dependency changes would be much easier and safer.

inirudebwoy commented 9 years ago

I have to admit the tests are very useful. Didn't feel quite confident with them at first, right now I know exactly where I was wrong. Nice.

peritus commented 8 years ago

Sorry, I don't think bumpversion will support this anytime soon.

Perhaps you can file a bug with configparser and bumpversion will (eventually) inherit this feature from there ?

peritus commented 8 years ago

A workaround might be to use a .bumpversion.cfg will without comments that bumpversion is allowed to mess with and keep your well-commented setup.cfg just for all things that are not about bumpversion.

schuderer commented 5 years ago

Thanks for posting the workaround. I was also trying to consolidate the many test/build/deploy-related files in my repository a bit.

I see that bumpversion wants to stick to using ConfigParser, and that's cool. Though when I look at it, bumpversion right now is using different mechanisms for updating the version string in the config file vs. in source code files (ConfigParser for one, the parsing mechanism for the other).

I for one wouldn't blame the maintainers as introducing any inconsistencies ;) (rather remove one!) if bumpversion would use ConfigParser only for reading its own config, and would use the same parsing mechanism for updating the version string in all files. Opinions?