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 miscast of current_version #111

Merged
merged 1 commit into from
Dec 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bumpversion/config/files_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def read_ini_file(file_path: Path) -> Dict[str, Any]: # noqa: C901
section_parts = section_name.split(":")
num_parts = len(section_parts)
options = {key: autocast.autocast_value(val) for key, val in config_parser.items(section_name)}
if "current_version" in options:
options["current_version"] = str(options["current_version"])

if num_parts == 1: # bumpversion section
bumpversion_options.update(options)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_config/test_files_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,22 @@ def test_utf8_message_from_config_file(tmp_path: Path, cfg_file):
cfg = config.get_configuration(cfg_path)

assert cfg.message == "Nová verze: {current_version} ☃, {new_version} ☀"


def test_current_version_is_always_a_string(tmp_path: Path):
cfg_path = tmp_path / ".bumpversion.cfg"
initial_config = (
"[bumpversion]\n"
"current_version = 2\n"
"commit = False\n"
"tag = False\n"
"parse = (?P<major>\d+)\n"
"serialize = \n"
" {major}\n"
)
cfg_path.write_bytes(initial_config.encode("utf-8"))

with inside_dir(tmp_path):
cfg = config.get_configuration(cfg_path)

assert cfg.current_version == "2"