mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
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:
parent
8a43a65557
commit
06b3d91da0
8 changed files with 37 additions and 9 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue