From 26502dfd0be4e223a0a4687066a1779ebf3552fb Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 12 Jan 2015 09:35:05 -0800 Subject: [PATCH] Default arguments from hooks.yaml --- pre_commit/clientlib/validate_config.py | 1 - pre_commit/clientlib/validate_manifest.py | 7 +++++++ testing/resources/arg_per_line_hooks_repo/hooks.yaml | 1 + tests/manifest_test.py | 2 ++ tests/repository_test.py | 4 +++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pre_commit/clientlib/validate_config.py b/pre_commit/clientlib/validate_config.py index a14aee65..c76ade2c 100644 --- a/pre_commit/clientlib/validate_config.py +++ b/pre_commit/clientlib/validate_config.py @@ -30,7 +30,6 @@ CONFIG_JSON_SCHEMA = { 'language_version': {'type': 'string'}, 'args': { 'type': 'array', - 'default': [], 'items': {'type': 'string'}, }, }, diff --git a/pre_commit/clientlib/validate_manifest.py b/pre_commit/clientlib/validate_manifest.py index b294a578..283d7c40 100644 --- a/pre_commit/clientlib/validate_manifest.py +++ b/pre_commit/clientlib/validate_manifest.py @@ -24,6 +24,13 @@ MANIFEST_JSON_SCHEMA = { 'language_version': {'type': 'string', 'default': 'default'}, 'files': {'type': 'string'}, 'expected_return_value': {'type': 'number', 'default': 0}, + 'args': { + 'type': 'array', + 'default': [], + 'items': { + 'type': 'string', + }, + }, }, 'required': ['id', 'name', 'entry', 'language', 'files'], }, diff --git a/testing/resources/arg_per_line_hooks_repo/hooks.yaml b/testing/resources/arg_per_line_hooks_repo/hooks.yaml index ee1f9e9e..4c101db2 100644 --- a/testing/resources/arg_per_line_hooks_repo/hooks.yaml +++ b/testing/resources/arg_per_line_hooks_repo/hooks.yaml @@ -3,3 +3,4 @@ entry: bin/hook.sh language: script files: '' + args: [hello, world] diff --git a/tests/manifest_test.py b/tests/manifest_test.py index 89bc5943..ba30d428 100644 --- a/tests/manifest_test.py +++ b/tests/manifest_test.py @@ -19,6 +19,7 @@ def manifest(store, tmpdir_factory): def test_manifest_contents(manifest): # Should just retrieve the manifest contents assert manifest.manifest_contents == [{ + 'args': [], 'description': '', 'entry': 'bin/hook.sh', 'expected_return_value': 0, @@ -32,6 +33,7 @@ def test_manifest_contents(manifest): def test_hooks(manifest): assert manifest.hooks['bash_hook'] == { + 'args': [], 'description': '', 'entry': 'bin/hook.sh', 'expected_return_value': 0, diff --git a/tests/repository_test.py b/tests/repository_test.py index 089ea35d..2e4d89bc 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -113,7 +113,9 @@ def test_run_a_script_hook(tmpdir_factory, store): def test_run_hook_with_spaced_args(tmpdir_factory, store): _test_hook_repo( tmpdir_factory, store, 'arg_per_line_hooks_repo', - 'arg-per-line', ['foo bar', 'baz'], 'arg: foo bar\narg: baz\n', + 'arg-per-line', + ['foo bar', 'baz'], + 'arg: hello\narg: world\narg: foo bar\narg: baz\n', )