Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b684520

Browse files
committed
Merge pull request #185 from pre-commit/default_args_from_hooks_yaml
Default arguments from hooks.yaml
2 parents 78c682a + 26502df commit b684520

5 files changed

Lines changed: 13 additions & 2 deletions

File tree

pre_commit/clientlib/validate_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class InvalidConfigError(FatalError):
3030
'language_version': {'type': 'string'},
3131
'args': {
3232
'type': 'array',
33-
'default': [],
3433
'items': {'type': 'string'},
3534
},
3635
},

pre_commit/clientlib/validate_manifest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class InvalidManifestError(ValueError):
2424
'language_version': {'type': 'string', 'default': 'default'},
2525
'files': {'type': 'string'},
2626
'expected_return_value': {'type': 'number', 'default': 0},
27+
'args': {
28+
'type': 'array',
29+
'default': [],
30+
'items': {
31+
'type': 'string',
32+
},
33+
},
2734
},
2835
'required': ['id', 'name', 'entry', 'language', 'files'],
2936
},

testing/resources/arg_per_line_hooks_repo/hooks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
entry: bin/hook.sh
44
language: script
55
files: ''
6+
args: [hello, world]

tests/manifest_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def manifest(store, tmpdir_factory):
1919
def test_manifest_contents(manifest):
2020
# Should just retrieve the manifest contents
2121
assert manifest.manifest_contents == [{
22+
'args': [],
2223
'description': '',
2324
'entry': 'bin/hook.sh',
2425
'expected_return_value': 0,
@@ -32,6 +33,7 @@ def test_manifest_contents(manifest):
3233

3334
def test_hooks(manifest):
3435
assert manifest.hooks['bash_hook'] == {
36+
'args': [],
3537
'description': '',
3638
'entry': 'bin/hook.sh',
3739
'expected_return_value': 0,

tests/repository_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def test_run_a_script_hook(tmpdir_factory, store):
113113
def test_run_hook_with_spaced_args(tmpdir_factory, store):
114114
_test_hook_repo(
115115
tmpdir_factory, store, 'arg_per_line_hooks_repo',
116-
'arg-per-line', ['foo bar', 'baz'], 'arg: foo bar\narg: baz\n',
116+
'arg-per-line',
117+
['foo bar', 'baz'],
118+
'arg: hello\narg: world\narg: foo bar\narg: baz\n',
117119
)
118120

119121

0 commit comments

Comments
 (0)