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

Added encoding support #154

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Added encoding support #154

wants to merge 4 commits into from

Conversation

4hopp
Copy link

@4hopp 4hopp commented Aug 21, 2020

Hi there,

please add encoding support for files to be modified. This feature is very important to us as we maintain many files that use to have latin1 encoding for legacy reasons.

(An alternative solution might be to read files with binary mode; I have not tested this, though, and there might be sideeffects in doing so.)

Cheers,
Joshua Hopp

Copy link
Collaborator

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In itself this looks like a reasonable change, but how is the user expected to use this? Are you using bump2version more as a library than as a CLI tool?

@4hopp
Copy link
Author

4hopp commented Aug 31, 2020

We are using bump2version as a CLI tool.

If a file that is to be modified by bump2version has a non-utf8 encoding, then this has to be stated in the configuration file. E.g.:

[bumpversion]
...

[bumpversion:file:my_file.txt]
encoding = latin1
search = "{current_version}"
replace = "{new_version}"

(That way, bump2version will not raise an exception if the file is latin1 encoded and there are, for example, german umlauts in the file.)

@ekohl
Copy link
Collaborator

ekohl commented Aug 31, 2020

Could you add that to the README? With that I think this should be ok to merge. Ideally it would also have a test.

@4hopp
Copy link
Author

4hopp commented Nov 18, 2020

I've added documentation to the README and a test.

@florisla
Copy link
Collaborator

The test should also verify that the file content is still intact in the correct encoding. I'll take a look.

@florisla
Copy link
Collaborator

Hi 4hopp, I extended the test a bit.

If you approve that merge in your branch (next time, create a separate feature branch for it!), then this can go in.

@florisla florisla assigned 4hopp and unassigned florisla Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants