From 31a3b2ecb6cb066bce7a1d302a4a949a2c7c6424 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 4 Jul 2014 11:10:42 -0700 Subject: [PATCH] Install hooks before attempting to run anything --- pre_commit/runner.py | 5 ++++- .../resources/consumer_repo/.pre-commit-config.yaml | 13 ------------- tests/runner_test.py | 11 +++-------- 3 files changed, 7 insertions(+), 22 deletions(-) delete mode 100644 testing/resources/consumer_repo/.pre-commit-config.yaml diff --git a/pre_commit/runner.py b/pre_commit/runner.py index 23204df4..e65f467b 100644 --- a/pre_commit/runner.py +++ b/pre_commit/runner.py @@ -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): diff --git a/testing/resources/consumer_repo/.pre-commit-config.yaml b/testing/resources/consumer_repo/.pre-commit-config.yaml deleted file mode 100644 index 0f9b5642..00000000 --- a/testing/resources/consumer_repo/.pre-commit-config.yaml +++ /dev/null @@ -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 diff --git a/tests/runner_test.py b/tests/runner_test.py index 76401650..075f86d6 100644 --- a/tests/runner_test.py +++ b/tests/runner_test.py @@ -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():