Added the useful thinking bit of the autoupdate and tests. · precommit/pre-commit@49da1ba · GitHub
Skip to content

Commit 49da1ba

Browse files
committed
Added the useful thinking bit of the autoupdate and tests.
1 parent d8f8f5e commit 49da1ba

5 files changed

Lines changed: 144 additions & 8 deletions

File tree

pre_commit/commands.py

Lines changed: 47 additions & 0 deletions

pre_commit/run.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,7 @@ def run(argv):
100100

101101
subparsers.add_parser('uninstall', help='Uninstall the pre-commit script.')
102102

103-
execute_hook = subparsers.add_parser(
104-
'execute-hook', help='Run a single hook.'
105-
)
106-
execute_hook.add_argument('hook', help='The hook-id to run.')
107-
execute_hook.add_argument(
108-
'--all-files', '-a', action='store_true', default=False,
109-
help='Run on all the files in the repo.',
110-
)
103+
subparsers.add_parser('autoupdate', help='Auto-update hooks config.')
111104

112105
run = subparsers.add_parser('run', help='Run hooks.')
113106
run.add_argument('hook', nargs='?', help='A single hook-id to run'),
@@ -130,6 +123,8 @@ def run(argv):
130123
return commands.install(runner)
131124
elif args.command == 'uninstall':
132125
return commands.uninstall(runner)
126+
elif args.command == 'autoupdate':
127+
return commands.autoupdate(runner)
133128
elif args.command == 'run':
134129
if args.hook:
135130
return run_single_hook(runner, args.hook, all_files=args.all_files)

testing/auto_namedtuple.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import collections
3+
4+
def auto_namedtuple(classname='auto_namedtuple', **kwargs):
5+
"""Returns an automatic namedtuple object.
6+
7+
Args:
8+
classname - The class name for the returned object.
9+
**kwargs - Properties to give the returned object.
10+
"""
11+
return (collections.namedtuple(classname, kwargs.keys())(**kwargs))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- id: bar
2+
name: Bar
3+
entry: bar
4+
language: python

tests/commands_test.py

Lines changed: 79 additions & 0 deletions

0 commit comments

Comments
 (0)