Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31a3b2e

Browse files
committed
Install hooks before attempting to run anything
1 parent 76ffb36 commit 31a3b2e

3 files changed

Lines changed: 7 additions & 22 deletions

File tree

pre_commit/runner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def config_file_path(self):
3737
def repositories(self):
3838
"""Returns a tuple of the configured repositories."""
3939
config = load_config(self.config_file_path)
40-
return tuple(Repository.create(x, self.store) for x in config)
40+
repositories = tuple(Repository.create(x, self.store) for x in config)
41+
for repository in repositories:
42+
repository.require_installed()
43+
return repositories
4144

4245
@cached_property
4346
def pre_commit_path(self):

testing/resources/consumer_repo/.pre-commit-config.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/runner_test.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pre_commit.constants as C
99
from pre_commit.runner import Runner
1010
from testing.fixtures import git_dir
11-
from testing.fixtures import make_repo
11+
from testing.fixtures import make_consuming_repo
1212

1313

1414
def test_init_has_no_side_effects(tmpdir):
@@ -47,14 +47,9 @@ def test_config_file_path():
4747

4848

4949
def test_repositories(tmpdir_factory, mock_out_store_directory):
50-
# TODO: make this not have external deps
51-
path = make_repo(tmpdir_factory, 'consumer_repo')
50+
path = make_consuming_repo(tmpdir_factory, 'script_hooks_repo')
5251
runner = Runner(path)
53-
assert len(runner.repositories) == 2
54-
assert [repo.repo_url for repo in runner.repositories] == [
55-
'[email protected]:pre-commit/pre-commit-hooks',
56-
'[email protected]:pre-commit/pre-commit',
57-
]
52+
assert len(runner.repositories) == 1
5853

5954

6055
def test_pre_commit_path():

0 commit comments

Comments
 (0)