Skip to content

scm

Version control system management.

Classes

Git

Bases: SourceCodeManager

Git implementation.

Functions

add_path classmethod
add_path(path: Union[str, Path]) -> None

Add a path to the VCS.

assert_nondirty classmethod
assert_nondirty() -> None

Assert that the working directory is not dirty.

latest_tag_info classmethod
latest_tag_info(
    tag_name: str, parse_pattern: str
) -> SCMInfo

Return information about the latest tag.

tag classmethod
tag(
    name: str,
    sign: bool = False,
    message: Optional[str] = None,
) -> None

Create a tag of the new_version in VCS.

If only name is given, bumpversion uses a lightweight tag. Otherwise, it uses an annotated tag.

Parameters:

name

The name of the tag

TYPE: str

sign

True to sign the tag

TYPE: bool

DEFAULT: False

message

An optional message to annotate the tag.

TYPE: Optional[str]

DEFAULT: None

Mercurial

Bases: SourceCodeManager

Mercurial implementation.

Functions

add_path classmethod
add_path(path: Union[str, Path]) -> None

Add a path to the VCS.

assert_nondirty classmethod
assert_nondirty() -> None

Assert that the working directory is clean.

latest_tag_info classmethod
latest_tag_info(
    tag_name: str, parse_pattern: str
) -> SCMInfo

Return information about the latest tag.

tag classmethod
tag(
    name: str,
    sign: bool = False,
    message: Optional[str] = None,
) -> None

Create a tag of the new_version in VCS.

If only name is given, bumpversion uses a lightweight tag. Otherwise, it uses an annotated tag.

Parameters:

name

The name of the tag

TYPE: str

sign

True to sign the tag

TYPE: bool

DEFAULT: False

message

A optional message to annotate the tag.

TYPE: Optional[str]

DEFAULT: None

Raises:

SignedTagsError

If sign is True

SCMInfo dataclass

SCMInfo(
    tool: Optional[Type[SourceCodeManager]] = None,
    commit_sha: Optional[str] = None,
    distance_to_latest_tag: int = 0,
    current_version: Optional[str] = None,
    current_tag: Optional[str] = None,
    branch_name: Optional[str] = None,
    short_branch_name: Optional[str] = None,
    repository_root: Optional[Path] = None,
    dirty: Optional[bool] = None,
)

Information about the current source code manager and state.

Functions

path_in_repo
path_in_repo(path: Union[Path, str]) -> bool

Return whether a path is inside this repository.

SourceCodeManager

Base class for version control systems.

Functions

add_path classmethod
add_path(path: Union[str, Path]) -> None

Add a path to the VCS.

assert_nondirty classmethod
assert_nondirty() -> None

Assert that the working directory is not dirty.

commit classmethod
commit(
    message: str,
    current_version: str,
    new_version: str,
    extra_args: Optional[list] = None,
) -> None

Commit the changes.

commit_to_scm classmethod
commit_to_scm(
    files: List[Union[str, Path]],
    config: Config,
    context: MutableMapping,
    extra_args: Optional[List[str]] = None,
    dry_run: bool = False,
) -> None

Commit the files to the source code management system.

format_and_raise_error classmethod
format_and_raise_error(
    exc: Union[TypeError, subprocess.CalledProcessError]
) -> None

Format the error message from an exception and re-raise it as a BumpVersionError.

get_all_tags classmethod
get_all_tags() -> List[str]

Return all tags in VCS.

get_version_from_tag classmethod
get_version_from_tag(
    tag: str, tag_name: str, parse_pattern: str
) -> Optional[str]

Return the version from a tag.

is_usable classmethod
is_usable() -> bool

Is the VCS implementation usable.

latest_tag_info classmethod
latest_tag_info(
    tag_name: str, parse_pattern: str
) -> SCMInfo

Return information about the latest tag.

tag classmethod
tag(
    name: str,
    sign: bool = False,
    message: Optional[str] = None,
) -> None

Create a tag of the new_version in VCS.

tag_in_scm classmethod
tag_in_scm(
    config: Config,
    context: MutableMapping,
    dry_run: bool = False,
) -> None

Tag the current commit in the source code management system.

Functions

get_scm_info

get_scm_info(tag_name: str, parse_pattern: str) -> SCMInfo

Return a dict with the latest source code management info.