Skip to content
Open
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
14 changes: 10 additions & 4 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def main(original_args=None):

# store the new version
_update_config_file(
config, config_file, config_newlines, config_file_exists, args.new_version, args.dry_run,
config, config_file, config_newlines, config_file_exists, args.new_version, args.dry_run, args.no_update_config,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we bypass _update_config_file altogether in case of no_update_config ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Could do that too, would you prefer that? Was trying to avoid flow changes as much as possible.

)

# commit and tag
Expand Down Expand Up @@ -294,7 +294,7 @@ def _load_configuration(config_file, explicit_config, defaults):
except NoOptionError:
pass # no default value then ;)

for boolvaluename in ("commit", "tag", "dry_run"):
for boolvaluename in ("commit", "tag", "dry_run", "no_update_config"):
try:
defaults[boolvaluename] = config.getboolean(
"bumpversion", boolvaluename
Expand Down Expand Up @@ -411,6 +411,12 @@ def _parse_arguments_phase_2(args, known_args, defaults, root_parser):
help="Template for complete string to replace",
default=defaults.get("replace", "{new_version}"),
)
parser2.add_argument(
"--no-update-config",
action="store_true",
help="Do not update the config file with current_version",
default=defaults.get("no_update_config", False),
)
known_args, remaining_argv = parser2.parse_known_args(args)

defaults.update(vars(known_args))
Expand Down Expand Up @@ -632,12 +638,12 @@ def _log_list(config, new_version):


def _update_config_file(
config, config_file, config_newlines, config_file_exists, new_version, dry_run,
config, config_file, config_newlines, config_file_exists, new_version, dry_run, no_update_config,
):
config.set("bumpversion", "current_version", new_version)
new_config = io.StringIO()
try:
write_to_config_file = (not dry_run) and config_file_exists
write_to_config_file = (not dry_run) and (not no_update_config) and config_file_exists

logger.info(
"%s to config file %s:",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def _mock_calls_to_string(called_mock):
{current_version})
--replace REPLACE Template for complete string to replace (default:
{new_version})
--no-update-config Do not update the config file with current_version
(default: False)
--current-version VERSION
Version that needs to be updated (default: None)
--no-configured-files
Expand Down