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

Fix newlines in config files #98

Merged
merged 4 commits into from
Jan 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def _update_config_file(

if write_to_config_file:
with open(config_file, "wt", encoding="utf-8", newline=config_newlines) as f:
f.write(new_config.getvalue())
f.write(new_config.getvalue().strip() + "\n")

except UnicodeEncodeError:
warnings.warn(
Expand Down
8 changes: 6 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def test_config_file_is_updated(tmpdir):
current_version = 0.0.14

[bumpversion:file:file3]

""" == tmpdir.join(".bumpversion.cfg").read()


Expand Down Expand Up @@ -1990,7 +1989,12 @@ def test_retain_newline(tmpdir, configfile, newline):
main(["major"])

assert newline in tmpdir.join("file.py").read_binary()
assert newline in tmpdir.join(configfile).read_binary()
new_config = tmpdir.join(configfile).read_binary()
assert newline in new_config

# Ensure there is only a single newline (not two) at the end of the file
# and that it is of the right type
assert new_config.endswith(b"[bumpversion:file:file.py]" + newline)


class TestSplitArgsInOptionalAndPositional:
Expand Down