mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Refactored how the installer works
This commit is contained in:
parent
8b0247e17f
commit
abea886a3d
8 changed files with 105 additions and 70 deletions
20
pre_commit/hooks_workspace.py
Normal file
20
pre_commit/hooks_workspace.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue