mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
Merge pull request #137 from pre-commit/install_before_running
Install hooks before attempting to run anything
This commit is contained in:
@@ -37,7 +37,10 @@ class Runner(object):
|
||||
def repositories(self):
|
||||
"""Returns a tuple of the configured repositories."""
|
||||
config = load_config(self.config_file_path)
|
||||
return tuple(Repository.create(x, self.store) for x in config)
|
||||
repositories = tuple(Repository.create(x, self.store) for x in config)
|
||||
for repository in repositories:
|
||||
repository.require_installed()
|
||||
return repositories
|
||||
|
||||
@cached_property
|
||||
def pre_commit_path(self):
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
- repo: git@github.com:pre-commit/pre-commit-hooks
|
||||
sha: bec87f6c87284ea15dbcf7801810404c8036bab4
|
||||
hooks:
|
||||
- id: pyflakes
|
||||
- id: debug-statements
|
||||
- id: trailing-whitespace
|
||||
- id: name-tests-test
|
||||
- id: end-of-file-fixer
|
||||
- repo: git@github.com:pre-commit/pre-commit
|
||||
sha: c62c1a3b513ab9e057e85a5e950bd7c438371076
|
||||
hooks:
|
||||
- id: validate_manifest
|
||||
- id: validate_config
|
||||
@@ -8,7 +8,7 @@ from plumbum import local
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.runner import Runner
|
||||
from testing.fixtures import git_dir
|
||||
from testing.fixtures import make_repo
|
||||
from testing.fixtures import make_consuming_repo
|
||||
|
||||
|
||||
def test_init_has_no_side_effects(tmpdir):
|
||||
@@ -47,14 +47,9 @@ def test_config_file_path():
|
||||
|
||||
|
||||
def test_repositories(tmpdir_factory, mock_out_store_directory):
|
||||
# TODO: make this not have external deps
|
||||
path = make_repo(tmpdir_factory, 'consumer_repo')
|
||||
path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
|
||||
runner = Runner(path)
|
||||
assert len(runner.repositories) == 2
|
||||
assert [repo.repo_url for repo in runner.repositories] == [
|
||||
'git@github.com:pre-commit/pre-commit-hooks',
|
||||
'git@github.com:pre-commit/pre-commit',
|
||||
]
|
||||
assert len(runner.repositories) == 1
|
||||
|
||||
|
||||
def test_pre_commit_path():
|
||||
|
||||
Reference in New Issue
Block a user