Added the additional_dependencies config parameter

Added the ability to specify additional dependencies to be installed in
the pre-commit environment. Fixed broken tests.
This commit is contained in:
Tobias Macey 2015-11-19 12:29:41 -05:00
parent 8a43a65557
commit 06b3d91da0
8 changed files with 37 additions and 9 deletions

View file

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import logging
import shutil
from collections import defaultdict
from cached_property import cached_property
@ -49,6 +50,14 @@ class Repository(object):
for _, hook in self.hooks
)
@cached_property
def additional_dependencies(self):
dep_dict = defaultdict(lambda: defaultdict(set))
for _, hook in self.hooks:
dep_dict[hook['language']][hook['language_version']].update(
hook.get('dependencies', []))
return dep_dict
@cached_property
def hooks(self):
# TODO: merging in manifest dicts is a smell imo
@ -107,7 +116,9 @@ class Repository(object):
if self.cmd_runner.exists(directory):
shutil.rmtree(self.cmd_runner.path(directory))
language.install_environment(self.cmd_runner, language_version)
language.install_environment(
self.cmd_runner, language_version,
self.additional_dependencies[language_name][language_version])
# Touch the .installed file (atomic) to indicate we've installed
open(self.cmd_runner.path(directory, '.installed'), 'w').close()