Skip to content

Commit a49a34e

Browse files
committed
Add identity meta hook
1 parent d2b92e8 commit a49a34e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

pre_commit/meta_hooks/identity.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys
2+
3+
from pre_commit import output
4+
5+
6+
def main(argv=None):
7+
argv = argv if argv is not None else sys.argv[1:]
8+
for arg in argv:
9+
output.write_line(arg)
10+
11+
12+
if __name__ == '__main__':
13+
exit(main())

pre_commit/repository.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def manifest_hooks(self):
237237
# The hooks are imported here to prevent circular imports.
238238
from pre_commit.meta_hooks import check_hooks_apply
239239
from pre_commit.meta_hooks import check_useless_excludes
240+
from pre_commit.meta_hooks import identity
240241

241242
def _make_entry(mod):
242243
"""the hook `entry` is passed through `shlex.split()` by the
@@ -260,6 +261,13 @@ def _make_entry(mod):
260261
'language': 'system',
261262
'entry': _make_entry(check_useless_excludes),
262263
},
264+
{
265+
'id': 'identity',
266+
'name': 'identity',
267+
'language': 'system',
268+
'verbose': True,
269+
'entry': _make_entry(identity),
270+
},
263271
]
264272

265273
return {

tests/meta_hooks/identity_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pre_commit.meta_hooks import identity
2+
3+
4+
def test_identity(cap_out):
5+
assert not identity.main(('a', 'b', 'c'))
6+
assert cap_out.get() == 'a\nb\nc\n'

0 commit comments

Comments
 (0)