diff --git a/bumpversion/cli.py b/bumpversion/cli.py index b107e10..d627d70 100644 --- a/bumpversion/cli.py +++ b/bumpversion/cli.py @@ -327,6 +327,9 @@ def _load_configuration(config_file, explicit_config, defaults): ) ThisVersionPartConfiguration = ConfiguredVersionPartConfiguration + if config.has_option(section_name, 'independent'): + section_config['independent'] = config.getboolean(section_name, 'independent') + part_configs[section_value] = ThisVersionPartConfiguration( **section_config ) diff --git a/bumpversion/functions.py b/bumpversion/functions.py index 12ba6c9..9235f0b 100644 --- a/bumpversion/functions.py +++ b/bumpversion/functions.py @@ -17,7 +17,7 @@ class NumericFunction: FIRST_NUMERIC = re.compile(r"([^\d]*)(\d+)(.*)") - def __init__(self, first_value=None): + def __init__(self, first_value=None, independent=False): if first_value is not None: try: @@ -33,6 +33,7 @@ def __init__(self, first_value=None): self.first_value = str(first_value) self.optional_value = self.first_value + self.independent = independent def bump(self, value): part_prefix, part_numeric, part_suffix = self.FIRST_NUMERIC.search( @@ -57,7 +58,7 @@ class ValuesFunction: you get a ValueError exception. """ - def __init__(self, values, optional_value=None, first_value=None): + def __init__(self, values, optional_value=None, first_value=None, independent=False): if not values: raise ValueError("Version part values cannot be empty") @@ -87,6 +88,7 @@ def __init__(self, values, optional_value=None, first_value=None): ) self.first_value = first_value + self.independent = independent def bump(self, value): try: diff --git a/bumpversion/version_part.py b/bumpversion/version_part.py index cb8c2fd..cf3f4e9 100644 --- a/bumpversion/version_part.py +++ b/bumpversion/version_part.py @@ -30,6 +30,10 @@ def first_value(self): def optional_value(self): return str(self.function.optional_value) + @property + def independent(self): + return self.function.independent + def bump(self, value=None): return self.function.bump(value) @@ -73,6 +77,9 @@ def bump(self): def is_optional(self): return self.value == self.config.optional_value + def is_independent(self): + return self.config.independent + def __format__(self, format_spec): return self.value @@ -117,7 +124,7 @@ def bump(self, part_name, order): if label == part_name: new_values[label] = self._values[label].bump() bumped = True - elif bumped: + elif bumped and not self._values[label].is_independent(): new_values[label] = self._values[label].null() else: new_values[label] = self._values[label].copy()