Implement Store. pre-commit now installs files to ~/.pre-commit

This commit is contained in:
Anthony Sottile 2014-04-20 22:41:14 -07:00
parent 26af2cecab
commit 479eb51873
16 changed files with 457 additions and 234 deletions

View file

@ -4,8 +4,8 @@ import os.path
import pre_commit.constants as C
from pre_commit import git
from pre_commit.clientlib.validate_config import load_config
from pre_commit.prefixed_command_runner import PrefixedCommandRunner
from pre_commit.repository import Repository
from pre_commit.store import Store
from pre_commit.util import cached_property
@ -27,10 +27,6 @@ class Runner(object):
os.chdir(root)
return cls(root)
@cached_property
def hooks_workspace_path(self):
return os.path.join(self.git_root, C.HOOKS_WORKSPACE)
@cached_property
def config_file_path(self):
return os.path.join(self.git_root, C.CONFIG_FILE)
@ -39,7 +35,7 @@ class Runner(object):
def repositories(self):
"""Returns a tuple of the configured repositories."""
config = load_config(self.config_file_path)
return tuple(Repository(x) for x in config)
return tuple(Repository.create(x, self.store) for x in config)
@cached_property
def pre_commit_path(self):
@ -47,4 +43,9 @@ class Runner(object):
@cached_property
def cmd_runner(self):
return PrefixedCommandRunner(self.hooks_workspace_path)
# TODO: remove this and inline runner.store.cmd_runner
return self.store.cmd_runner
@cached_property
def store(self):
return Store()