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 uses trailing spaces and tabs for it's configuration #78

Open keimlink opened 9 years ago

keimlink commented 9 years ago

bumpversion uses trailing spaces and tabs if it updates it's own configuration. As long as the configuration is kept in a separate .bumpversion file this is just a cosmetic issue.

But since release 0.5.1 bumpversion allows users to configure it by using setup.cfg. Unfortunately setup.cfg will be messed up by bumpversion by replacing spaces with tabs for indentation and by adding trailing spaces to equal signs.

The optimal solution would be if bumpversion could respect the indentation style that is used and add no trailing spaces at all.

peritus commented 9 years ago

Bumpversion uses ConfigParser underneath to read and write the configuration (both .bumpversion.cfg and setup.cfg). While I certainly have some influence on how the files are read and written (as in #75), your request might be too difficult for that. I'm still researching whether I can tell ConfigParser to write the file in the same manner it was read.

While I don't like software re-indenting and/or replacing tabs with spaces myself, what is the problem this causes with other software then reading setup.cfg ?

keimlink commented 9 years ago

I'm not sure if I understood your question the right way. If the configuration of bumpversion consists of several sections in setup.cfg and you bump the version, the sections are no longer at the same place as before. Furthermore trailing spaces added and leading spaces are converted to tabs. This creates a commit that looks awful.

Therefore we use a separate .bumpversion.cfg file so that setup.cfg is not messed up.

peritus commented 9 years ago

Yes, ConfigParser rewrites the whole file and I don't know if there's a way around that.

After that initial "awful looking" rewriting commit, is there a "real" (you know I hate tabs and trailing whitespace more than any other person, but if we let's set that aside for a moment) problem with other software also reading/writing setup.cfg (as was in #75) ?

Kaju-Bubanja commented 2 years ago

7 years later and I get bitten by this

mxmlnkn commented 7 months ago

Yes, ConfigParser rewrites the whole file and I don't know if there's a way around that.

As mentioned in a similar issue in setuptools, maybe do it like this:

  1. Generate new setup.cfg with ConfigParser
  2. Generate a diff ignoring whitespace changes with diff -w or an equivalent Python library.
  3. Apply the minimal non-whitespace-changing diff to the original setup.cfg.