-
Notifications
You must be signed in to change notification settings - Fork 133
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
Using bump2version and pre-commit hooks #124
Comments
Well it would be informative if you could share the error message of the failure :-) But I see you're using |
Maybe some more info since I also have problems with pre-commit hooks and bumpversion. More specifically my problem is connected to the [flake8]
exclude =
.git
__pycache__ Bumpversion seems to add whitespace after Maybe the original author has similar problems. Edit: The version I am using is |
I can confirm I have the same issue as @cbows described above with the trailing whitespace pre-commit hook. I've disabled this hook for now, but it would be nice if |
I am also having the same issue with bump2version, and the fix-trailing-whitespace precommit hook failing on setup.cfg |
I can also chime in that the |
Apparently this is caused by python One dirty solution is to strip the extra whitespace before writing the file: diff --git a/bumpversion/cli.py b/bumpversion/cli.py
index b107e10..378389d 100644
--- a/bumpversion/cli.py
+++ b/bumpversion/cli.py
@@ -646,11 +646,12 @@ def _update_config_file(
)
config.write(new_config)
- logger.info(new_config.getvalue())
+ config_text = new_config.getvalue().replace("= %s" % config_newlines, "=%s" % config_newlines)
+ logger.info(config_text)
if write_to_config_file:
with open(config_file, "wt", encoding="utf-8", newline=config_newlines) as f:
- f.write(new_config.getvalue().strip() + "\n")
+ f.write(config_text.strip() + config_newlines)
except UnicodeEncodeError:
warnings.warn( It this is acceptable I can open a PR including the fix and the test changes |
I also have a solution for this issue here: #163 |
@balrok If I understood correctly your approach, it looks absolutely sane |
Another workaround is to exclude - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: trailing-whitespace
exclude: setup.cfg But yeah, this isn't ideal, and it would be nice if bumpversion didn't modify any lines it doesn't need to. Even without the hook, if I edit |
Hi,
I have been using bump2version for a while. Thank you for maintaining it.
Most recently, I added pre-commit hooks to my workflow. Now, my bumpversion commands are always failing since I think it interferes with the pre-commit hooks.
I am using bumpversion's
--no-commit
flag for now and then commit manually. Is there a way to make them both work together ?Here's my bumpversion config:
And here's my pre commit hook config:
Let me know if you need more information from me.
The text was updated successfully, but these errors were encountered: