Support repos without hooks.yaml by reading a local config

If a repo does not have a hooks.yaml any hook ids are then looked for in
.pre-commit-hooks-config.yaml in the repo that is under test. It has the same
format as a standard hooks.yaml.

The purpose of this change is to avoid needing to mirror a linter repo just
to call it. Long term, tools could be reference by a URL or other source than
a git repo making having a mirror repo even more of a hassle.
This commit is contained in:
Sean Perry 2016-01-22 17:35:09 -08:00
parent b1e6063e12
commit 364da6a0a5
3 changed files with 30 additions and 9 deletions

View file

@ -17,7 +17,7 @@ from pre_commit.clientlib.validate_manifest import MANIFEST_JSON_SCHEMA
from pre_commit.jsonschema_extensions import apply_defaults
from pre_commit.languages.all import languages
from pre_commit.languages.helpers import environment_dir
from pre_commit.manifest import Manifest
from pre_commit.manifest import ExternalManifest, Manifest
from pre_commit.prefixed_command_runner import PrefixedCommandRunner
@ -102,7 +102,10 @@ class Repository(object):
@cached_property
def manifest(self):
return Manifest(self.repo_path_getter)
m = Manifest(self.repo_path_getter)
if not m.exists():
m = ExternalManifest(git.get_root())
return m
@cached_property
def cmd_runner(self):