peritus / bumpversion

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

2 newlines added at the end of .bumpversion.cfg file when bumping #179

Open arielnmz opened 6 years ago

arielnmz commented 6 years ago

Whenever you bump the .bumpversion.cfg file ends up with 2 newlines at the end

arielnmz commented 6 years ago

Since I don't want to fork I suggest the following patch as a fix:

Index: bumpversion/__init__.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- bumpversion/__init__.py (date 1435260711000)
+++ bumpversion/__init__.py (date 1522533107000)
@@ -860,7 +860,7 @@

         if write_to_config_file:
             with io.open(config_file, 'wb') as f:
-                f.write(new_config.getvalue().encode('utf-8'))
+                f.write((new_config.getvalue().strip()+'\n').encode('utf-8'))

     except UnicodeEncodeError:
         warnings.warn(

It just strips and appends a single newline at the end of the file, perhaps a better solution would be checking at the _write_section method of the RawConfigParser class, but this does the trick.

sharksforarms commented 6 years ago

See this fork https://github.com/c4urself/bump2version/