bumpversion.versioning.models
Models for managing versioning of software projects.
VersionComponent
class VersionComponent(values: Optional[list] = None, optional_value: Optional[str] = None, first_value: Union[str, int, None] = None, independent: bool = False, always_increment: bool = False, calver_format: Optional[str] = None, source: Optional[str] = None, value: Union[str, int, None] = None)Represent part of a version number.
Determines the PartFunction that rules how the part behaves when increased or reset based on the configuration given.
value
value: strThe value of the part.
copy
def copy() -> VersionComponentReturn a copy of the part.
bump
def bump() -> VersionComponentReturn a part with bumped value.
bump_to
def bump_to(value: str) -> VersionComponentReturn a part set to the given value. Raises a ValueError if the value is not valid for the part.
null
def null() -> VersionComponentReturn a part with first value.
is_optional
is_optional: boolIs the part optional?
is_independent
is_independent: boolIs the part independent of the other parts?
VersionComponentSpec
class VersionComponentSpec()Configuration of a version component.
This is used to read in the configuration from the bumpversion config file.
values
values: Optional[list] = NoneThe possible values for the component. If it and calver_format is None, the component is numeric.
optional_value
optional_value: Optional[str] = NoneThe value that is optional to include in the version.
- Defaults to first value in values or 0 in the case of numeric.
- Empty string means nothing is optional.
- CalVer components ignore this.
first_value
first_value: Union[str, int, None] = NoneThe first value to increment from.
independent
independent: bool = FalseIs the component independent of the other components?
always_increment
always_increment: bool = FalseShould the component always increment, even if it is not necessary?
calver_format
calver_format: Optional[str] = NoneThe format string for a CalVer component.
depends_on
depends_on: Optional[str] = NoneThe name of the component this component depends on.
set_always_increment_with_calver
def set_always_increment_with_calver(data: Any) -> AnySet always_increment to True if calver_format is present.
create_component
def create_component(value: Union[str, int, None] = None) -> VersionComponentGenerate a version component from the configuration.
VersionSpec
class VersionSpec(components: Dict[str, VersionComponentSpec], order: Optional[List[str]] = None)The specification of a version's components and their relationships.
create_version
def create_version(values: Dict[str, str]) -> VersionGenerate a version from the given values.
get_dependents
def get_dependents(component_name: str) -> List[str]Return the parts that depend on the given part.
Version
class Version(version_spec: VersionSpec, components: Dict[str, VersionComponent], original: Optional[str] = None)The specification of a version and its parts.
values
def values() -> Dict[str, VersionComponent]Return the values of the parts.
required_components
def required_components() -> List[str]Return the names of the parts that are required.
bump
def bump(component_name: str) -> VersionIncrease the value of the specified component, reset its dependents, and return a new Version.
bump_to
def bump_to(component_name: str, value: str) -> VersionSet the specified component to value, reset its dependents, and return a new Version.