getters#

find_hook(config: PrecommitConfig, search_pattern: str) Hook | None[source]#

Find pre-commit hook definition in pre-commit config.

find_repo(config: PrecommitConfig, search_pattern: str) Repo | None[source]#

Find pre-commit repo definition in pre-commit config.

find_repo_with_index(config: PrecommitConfig, search_pattern: str) tuple[int, Repo] | None[source]#

Find pre-commit repo definition and its index in pre-commit config.

get_latest_rev(repo_url: str, fallback: str = 'PLEASE-UPDATE') str[source]#

Fetch the latest release tag of a pre-commit hook repository.

Returns the highest version tag found through git ls-remote, or fallback when the tags cannot be fetched (for example when there is no internet connection).