mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #898 from pre-commit/identity
Add identity meta hook
This commit is contained in:
commit
7448e588ff
3 changed files with 27 additions and 0 deletions
13
pre_commit/meta_hooks/identity.py
Normal file
13
pre_commit/meta_hooks/identity.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from pre_commit import output
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv=None):
|
||||||
|
argv = argv if argv is not None else sys.argv[1:]
|
||||||
|
for arg in argv:
|
||||||
|
output.write_line(arg)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
exit(main())
|
||||||
|
|
@ -237,6 +237,7 @@ class MetaRepository(LocalRepository):
|
||||||
# The hooks are imported here to prevent circular imports.
|
# The hooks are imported here to prevent circular imports.
|
||||||
from pre_commit.meta_hooks import check_hooks_apply
|
from pre_commit.meta_hooks import check_hooks_apply
|
||||||
from pre_commit.meta_hooks import check_useless_excludes
|
from pre_commit.meta_hooks import check_useless_excludes
|
||||||
|
from pre_commit.meta_hooks import identity
|
||||||
|
|
||||||
def _make_entry(mod):
|
def _make_entry(mod):
|
||||||
"""the hook `entry` is passed through `shlex.split()` by the
|
"""the hook `entry` is passed through `shlex.split()` by the
|
||||||
|
|
@ -260,6 +261,13 @@ class MetaRepository(LocalRepository):
|
||||||
'language': 'system',
|
'language': 'system',
|
||||||
'entry': _make_entry(check_useless_excludes),
|
'entry': _make_entry(check_useless_excludes),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'id': 'identity',
|
||||||
|
'name': 'identity',
|
||||||
|
'language': 'system',
|
||||||
|
'verbose': True,
|
||||||
|
'entry': _make_entry(identity),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
6
tests/meta_hooks/identity_test.py
Normal file
6
tests/meta_hooks/identity_test.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
from pre_commit.meta_hooks import identity
|
||||||
|
|
||||||
|
|
||||||
|
def test_identity(cap_out):
|
||||||
|
assert not identity.main(('a', 'b', 'c'))
|
||||||
|
assert cap_out.get() == 'a\nb\nc\n'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue