bumpversion icon indicating copy to clipboard operation
bumpversion copied to clipboard

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

Open arielnmz opened this issue 7 years ago • 2 comments

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

arielnmz avatar Mar 31 '18 19:03 arielnmz

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.

arielnmz avatar Mar 31 '18 22:03 arielnmz

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

sharksforarms avatar Apr 18 '18 22:04 sharksforarms