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

Refactored configuration file updating. #101

Merged
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
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repos:
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
additional_dependencies: ["pydantic<2.0", "toml", "types-all"]
additional_dependencies: ["pydantic>2.0", "toml", "types-all"]
- repo: https://github.com/jsh9/pydoclint
rev: 0.3.8
hooks:
Expand All @@ -59,3 +59,5 @@ repos:
rev: 0.27.1
hooks:
- id: check-azure-pipelines
ci:
autofix_prs: false
8 changes: 6 additions & 2 deletions bumpversion/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from bumpversion.files import ConfiguredFile
from bumpversion.version_part import Version

from bumpversion.config import Config, update_config_file
from bumpversion.config import Config
from bumpversion.config.files import update_config_file, update_ini_config_file
from bumpversion.exceptions import ConfigurationError
from bumpversion.utils import get_context, key_val_string

Expand Down Expand Up @@ -81,7 +82,10 @@ def do_bump(

configured_files = resolve_file_config(config.files_to_modify, config.version_config)
modify_files(configured_files, version, next_version, ctx, dry_run)
update_config_file(config_file, config.current_version, next_version_str, dry_run)
if config_file and config_file.suffix in {".cfg", ".ini"}:
update_ini_config_file(config_file, config.current_version, next_version_str, dry_run)
else:
update_config_file(config_file, config, version, next_version, ctx, dry_run)

ctx = get_context(config, version, next_version)
ctx["new_version"] = next_version_str
Expand Down
6 changes: 3 additions & 3 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from bumpversion import __version__
from bumpversion.aliases import AliasedGroup
from bumpversion.bump import do_bump
from bumpversion.config import find_config_file, get_configuration
from bumpversion.config import get_configuration
from bumpversion.config.files import find_config_file
from bumpversion.files import ConfiguredFile, modify_files
from bumpversion.logging import setup_logging
from bumpversion.show import do_show, log_list
from bumpversion.ui import print_warning
from bumpversion.ui import print_warning, setup_logging
from bumpversion.utils import get_context, get_overrides

logger = logging.getLogger(__name__)
Expand Down
Loading