mypythontools_cicd.git package¶
Helpers with git and github functionality.
- mypythontools_cicd.git.check_branch(allowed_branches: Sequence[str])[source]¶
Check if project is opened with one of particular branches anr raise error if not.
- Parameters
allowed_branches (Sequence[str]) – Sequence of allowed branches.
- Raises
RuntimeError – If project is on branch that is not in allowed branches.
- mypythontools_cicd.git.check_tag(tag: str)[source]¶
Check if tag is not already in repo, so it can be created afterwards.
- Parameters
tag (str) – Tag name. E.g. ‘v.0.0.3’
- Raises
TagAlreadyExists – If tag already exists in repo.
- mypythontools_cicd.git.clone_locally(from_path: Union[Path, str], to_path: Union[Path, str])[source]¶
Copy file from one place to another. Main benefit is, that .gitignore is used, so things like venv is is not copied.
- Parameters
from_path (PathLike) – Source
to_path (PathLike) – Destination
- mypythontools_cicd.git.commit_all(commit_message: str, verbosity: typing_extensions.Literal[0, 1, 2] = 1)[source]¶
Stage all changes and create a commit.
- Parameters
commit_message (str) – Commit message.
verbosity (Literal[0, 1, 2], optional) – If 0, prints nothing, if 1, then one line description of what happened is printed. If 3, all the results from terminal are printed. Defaults to 1.
- mypythontools_cicd.git.push(tag: str | None = '__version__', tag_message: str = 'New version', verbosity: Literal[0, 1, 2] = 1) None [source]¶
Add tag and push.
If tag is __version__, then tag is inferred from __init__.py.
- Parameters
tag (str | None, optional) – Define tag used in push. If tag is ‘__version__’, than is automatically generated from __init__ version. E.g from ‘1.0.2’ to ‘v1.0.2’. Defaults to ‘__version__’.
tag_message (str, optional) – Message in annotated tag. Defaults to ‘New version’.
verbosity (Literal[0, 1, 2], optional) – If 0, prints nothing, if 1, then one line description of what happened is printed. If 3, all the results from terminal are printed. Defaults to 1.