mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
Implement no-dependency system and script hook types. Closes #39.
This commit is contained in:
parent
02660f7c0a
commit
c418f2b94e
14 changed files with 86 additions and 52 deletions
|
|
@ -59,45 +59,36 @@ def prints_cwd_repo(dummy_git_repo):
|
|||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def config_for_node_hooks_repo(node_hooks_repo):
|
||||
def script_hooks_repo(dummy_git_repo):
|
||||
yield _make_repo(dummy_git_repo, 'script_hooks_repo')
|
||||
|
||||
|
||||
def _make_config(path, hook_id, file_regex):
|
||||
config = {
|
||||
'repo': node_hooks_repo,
|
||||
'sha': git.get_head_sha(node_hooks_repo),
|
||||
'hooks': [{
|
||||
'id': 'foo',
|
||||
'files': '\.js$',
|
||||
}],
|
||||
'repo': path,
|
||||
'sha': git.get_head_sha(path),
|
||||
'hooks': [{'id': hook_id, 'files': file_regex}],
|
||||
}
|
||||
jsonschema.validate([config], CONFIG_JSON_SCHEMA)
|
||||
validate_config_extra([config])
|
||||
yield config
|
||||
return config
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def config_for_node_hooks_repo(node_hooks_repo):
|
||||
yield _make_config(node_hooks_repo, 'foo', '\.js$')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def config_for_python_hooks_repo(python_hooks_repo):
|
||||
config = {
|
||||
'repo': python_hooks_repo,
|
||||
'sha': git.get_head_sha(python_hooks_repo),
|
||||
'hooks': [{
|
||||
'id': 'foo',
|
||||
'files': '\.py$',
|
||||
}],
|
||||
}
|
||||
jsonschema.validate([config], CONFIG_JSON_SCHEMA)
|
||||
validate_config_extra([config])
|
||||
yield config
|
||||
yield _make_config(python_hooks_repo, 'foo', '\.py$')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def config_for_prints_cwd_repo(prints_cwd_repo):
|
||||
config = {
|
||||
'repo': prints_cwd_repo,
|
||||
'sha': git.get_head_sha(prints_cwd_repo),
|
||||
'hooks': [{
|
||||
'id': 'prints_cwd',
|
||||
'files': '\.py$',
|
||||
}],
|
||||
}
|
||||
jsonschema.validate([config], CONFIG_JSON_SCHEMA)
|
||||
validate_config_extra([config])
|
||||
yield config
|
||||
yield _make_config(prints_cwd_repo, 'prints_cwd', '^$')
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def config_for_script_hooks_repo(script_hooks_repo):
|
||||
yield _make_config(script_hooks_repo, 'bash_hook', '^$')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue