Skip to content
Open
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
22 changes: 18 additions & 4 deletions bumpversion/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from bumpversion.exceptions import (
IncompleteVersionRepresentationException,
MissingValueForSerializationException,
VersionNotFoundException,
WorkingDirectoryIsDirtyException,
)

Expand Down Expand Up @@ -121,7 +122,7 @@ def main(original_args=None):
for file_name
in (file_names or positionals[1:])
)
_check_files_contain_version(files, current_version, context)
_check_files_contain_version(files, current_version, context, args.ignore_missing_version)
_replace_version_in_files(files, current_version, new_version, args.dry_run, context)
_log_list(config, args.new_version)

Expand Down Expand Up @@ -294,7 +295,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", "ignore_missing_version"):
try:
defaults[boolvaluename] = config.getboolean(
"bumpversion", boolvaluename
Expand Down Expand Up @@ -473,6 +474,13 @@ def _parse_arguments_phase_3(remaining_argv, positionals, defaults, parser2):
help="Version that needs to be updated",
required="current_version" not in defaults,
)
parser3.add_argument(
"--ignore-missing-version",
action="store_true",
default=False,
dest="ignore_missing_version",
help="Ignore any missing version strings in files and skip those files.",
)
parser3.add_argument(
"--no-configured-files",
action="store_true",
Expand Down Expand Up @@ -611,14 +619,20 @@ def _determine_vcs_dirty(possible_vcses, defaults):
return None


def _check_files_contain_version(files, current_version, context):
def _check_files_contain_version(files, current_version, context, ignore_missing=False):
# make sure files exist and contain version string
logger.info(
"Asserting files %s contain the version string...",
", ".join([str(f) for f in files]),
)
for f in files:
f.should_contain_version(current_version, context)
try:
f.should_contain_version(current_version, context)
except VersionNotFoundException as e:
if ignore_missing:
logger.warning("Skipping file %s: %s", f, e)
else:
raise


def _replace_version_in_files(files, current_version, new_version, dry_run, context):
Expand Down