git ¤
This module contains Git utilities.
Functions:
-
assert_git_repo
–Assert that a directory is a Git repository.
-
get_latest_tag
–Get latest tag of a Git repository.
-
get_repo_root
–Get the root of a Git repository.
-
tmp_worktree
–Context manager that checks out the given reference in the given repository to a temporary worktree.
assert_git_repo ¤
get_latest_tag ¤
get_repo_root ¤
tmp_worktree ¤
Context manager that checks out the given reference in the given repository to a temporary worktree.
Parameters:
-
repo
(str | Path
, default:'.'
) –Path to the repository (i.e. the directory containing the
.git
directory) -
ref
(str
, default:'HEAD'
) –A Git reference such as a commit, tag or branch.
Yields:
-
Path
–The path to the temporary worktree.
Raises:
-
OSError
–If
repo
is not a valid.git
repository -
RuntimeError
–If the
git
executable is unavailable, or if it cannot create a worktree