Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bumpversion command adds a newline in bumpversion.cfg #58

Closed
pmav99 opened this issue Jan 20, 2019 · 6 comments · Fixed by #98
Closed

bumpversion command adds a newline in bumpversion.cfg #58

pmav99 opened this issue Jan 20, 2019 · 6 comments · Fixed by #98

Comments

@pmav99
Copy link

pmav99 commented Jan 20, 2019

I am using pre-commit and one of the hooks I use is is end-of-line-fixer:

end-of-file-fixer - Makes sure files end in a newline and only a newline.

This seems to be causing issues to bump2version. More specifically, bump2version seems to be adding an extra empty line at the end of .bumpversion.cfg which make the hook to fail. As a result, the commit is being aborted.

Is that extra line necessary?

@avilaton
Copy link

I used the exclude field to get around this

-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.2.3
    hooks:
    -   id: trailing-whitespace
    -   id: end-of-file-fixer
        exclude: '.bumpversion.cfg'

@pmav99
Copy link
Author

pmav99 commented Jan 22, 2019

@avilaton You are right, this is a viable workaround, but it still seems to be something that could be fixed directly on bump2version

pmav99 added a commit to pmav99/virtbuilder that referenced this issue Jan 25, 2019
@arielnmz
Copy link

arielnmz commented Jun 7, 2019

Related: peritus/bumpversion#179

Patch:

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(

Don't know if it'd still work

@jtrakk
Copy link

jtrakk commented Jun 19, 2019

Nice find, @arielnmz. I just tried that fix and it worked for me.

jtrakk added a commit to jtrakk/bump2version that referenced this issue Jul 19, 2019
@kyluca
Copy link
Contributor

kyluca commented Oct 31, 2019

Opened a new PR heavily inspired by the previous ones here, full credit to the previous authors :)

#98

jbweston added a commit to jbweston/qsim that referenced this issue Nov 12, 2019
Also disable end-of-file pre-commit checks, as bumpversion adds a
newline, see c4urself/bump2version#58.
@mazzma12
Copy link

mazzma12 commented Jun 6, 2023

mosdef-hub/gmso#602 is
still an issue for me with version 1.0.1, I had to add an exclude in the pre-commit config

    -   id: trailing-whitespace
        exclude: setup.cfg # https://github.com/c4urself/bump2version/issues/58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants