Implement no-dependency system and script hook types. Closes #39.

This commit is contained in:
Anthony Sottile
2014-03-30 15:15:13 -07:00
parent 02660f7c0a
commit c418f2b94e
14 changed files with 86 additions and 52 deletions

View File

@@ -2,6 +2,8 @@
from pre_commit.languages import node
from pre_commit.languages import python
from pre_commit.languages import ruby
from pre_commit.languages import script
from pre_commit.languages import system
# A language implements the following two functions in its module:
#
@@ -29,4 +31,9 @@ languages = {
'node': node,
'python': python,
'ruby': ruby,
'script': script,
'system': system,
}
all_languages = languages.keys()

View File

@@ -0,0 +1,13 @@
def install_environment(repo_cmd_runner):
"""Installation for script type is a noop."""
pass
def run_hook(repo_cmd_runner, hook, file_args):
return repo_cmd_runner.run(
['xargs', '{{prefix}}{0}'.format(hook['entry'])] + hook.get('args', []),
# TODO: this is duplicated in pre_commit/languages/helpers.py
stdin='\n'.join(list(file_args) + ['']),
retcode=None,
)

View File

@@ -0,0 +1,13 @@
def install_environment(repo_cmd_runner):
"""Installation for system type is a noop."""
pass
def run_hook(repo_cmd_runner, hook, file_args):
return repo_cmd_runner.run(
['xargs', hook['entry']] + hook.get('args', []),
# TODO: this is duplicated in pre_commit/languages/helpers.py
stdin='\n'.join(list(file_args) + ['']),
retcode=None,
)