Skip to content

bumpversion.hooks ​

Implementation of the hook interface.

PREFIX ​

python
PREFIX = 'BVHOOK_'

logger ​

python
logger = get_indented_logger(__name__)

SHELL_SYNTAX_RE ​

python
SHELL_SYNTAX_RE = re.compile('[|;&`$<>()\\n\\r]')

has_shell_syntax ​

python
def has_shell_syntax(script: str) -> bool

Return True if the command string contains shell metacharacters.

run_command ​

python
def run_command(script: str, environment: Optional[dict] = None) -> subprocess.CompletedProcess

Run a command using argv-based execution (shell=False).

base_env ​

python
def base_env(config: Config) -> Dict[str, str]

Provide the base environment variables.

scm_env ​

python
def scm_env(config: Config) -> Dict[str, str]

Provide the scm environment variables.

version_env ​

python
def version_env(version: Version, version_prefix: str) -> Dict[str, str]

Provide the environment variables for each version component with a prefix.

new_version_env ​

python
def new_version_env(config: Config, current_version: Version, new_version: Version) -> Dict[str, str]

Provide the environment dictionary for new_version serialized and tag name.

hook_context ​

python
def hook_context(config: Config, current_version: Version, new_version: Optional[Version] = None) -> Dict[str, str]

Build a context dictionary for formatting hook command strings.

Only version-related keys are included so that unrelated braces in a hook command are not accidentally substituted.

format_hooks ​

python
def format_hooks(hooks: List[str], context: Dict[str, str]) -> List[str]

Replace known version placeholders in hook command strings.

Placeholders that do not match a key in context are left untouched. Values are shell-quoted (except on Windows) so whitespace or quotes in a value cannot add argv elements.

get_setup_hook_env ​

python
def get_setup_hook_env(config: Config, current_version: Version) -> Dict[str, str]

Provide the environment dictionary for setup_hooks.

get_pre_commit_hook_env ​

python
def get_pre_commit_hook_env(config: Config, current_version: Version, new_version: Version) -> Dict[str, str]

Provide the environment dictionary for pre_commit_hooks.

get_post_commit_hook_env ​

python
def get_post_commit_hook_env(config: Config, current_version: Version, new_version: Version) -> Dict[str, str]

Provide the environment dictionary for post_commit_hooks.

run_hooks ​

python
def run_hooks(hooks: List[str], env: Dict[str, str], dry_run: bool = False, allow_shell_hooks: bool = False, context: Optional[Dict[str, str]] = None) -> None

Run a list of command-line programs, defaulting to safe argv-based execution.

context is used for placeholder substitution only when it is not None and allow_shell_hooks is false; None and {} both mean no substitution.

run_setup_hooks ​

python
def run_setup_hooks(config: Config, current_version: Version, dry_run: bool = False) -> None

Run the setup hooks.

run_pre_commit_hooks ​

python
def run_pre_commit_hooks(config: Config, current_version: Version, new_version: Version, dry_run: bool = False) -> None

Run the pre-commit hooks.

run_post_commit_hooks ​

python
def run_post_commit_hooks(config: Config, current_version: Version, new_version: Version, dry_run: bool = False) -> None

Run the post-commit hooks.