mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-01 06:20:33 -06:00
20 lines
512 B
Python
20 lines
512 B
Python
|
|
import contextlib
|
|
import os.path
|
|
from plumbum import local
|
|
|
|
import pre_commit.constants as C
|
|
from pre_commit import git
|
|
|
|
|
|
def get_pre_commit_dir_path():
|
|
return os.path.join(git.get_root(), C.HOOKS_WORKSPACE)
|
|
|
|
@contextlib.contextmanager
|
|
def in_hooks_workspace():
|
|
"""Change into the hooks workspace. If it does not exist create it."""
|
|
if not os.path.exists(get_pre_commit_dir_path()):
|
|
local.path(get_pre_commit_dir_path()).mkdir()
|
|
|
|
with local.cwd(get_pre_commit_dir_path()):
|
|
yield |