mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 10:01:46 +04:00
Add simple identify command
This commit is contained in:
parent
120eecaf89
commit
bb2b679ef0
2 changed files with 16 additions and 0 deletions
8
pre_commit/commands/identify.py
Normal file
8
pre_commit/commands/identify.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
from pre_commit import git
|
||||||
|
from pre_commit.file_classifier.classifier import classify
|
||||||
|
|
||||||
|
|
||||||
|
def identify(args):
|
||||||
|
# TODO: more useful output
|
||||||
|
# TODO: check whether file is in git repo first?
|
||||||
|
print(classify(args.path, git.guess_git_type_for_file(args.path)))
|
||||||
|
|
@ -10,6 +10,7 @@ from pre_commit import color
|
||||||
from pre_commit import five
|
from pre_commit import five
|
||||||
from pre_commit.commands.autoupdate import autoupdate
|
from pre_commit.commands.autoupdate import autoupdate
|
||||||
from pre_commit.commands.clean import clean
|
from pre_commit.commands.clean import clean
|
||||||
|
from pre_commit.commands.identify import identify
|
||||||
from pre_commit.commands.install_uninstall import install
|
from pre_commit.commands.install_uninstall import install
|
||||||
from pre_commit.commands.install_uninstall import uninstall
|
from pre_commit.commands.install_uninstall import uninstall
|
||||||
from pre_commit.commands.run import run
|
from pre_commit.commands.run import run
|
||||||
|
|
@ -67,6 +68,11 @@ def main(argv=None):
|
||||||
default='pre-commit',
|
default='pre-commit',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
identify_parser = subparsers.add_parser(
|
||||||
|
'identify', help='Identify a file, listing tags that apply to it',
|
||||||
|
)
|
||||||
|
identify_parser.add_argument('path')
|
||||||
|
|
||||||
subparsers.add_parser('clean', help='Clean out pre-commit files.')
|
subparsers.add_parser('clean', help='Clean out pre-commit files.')
|
||||||
|
|
||||||
subparsers.add_parser(
|
subparsers.add_parser(
|
||||||
|
|
@ -145,6 +151,8 @@ def main(argv=None):
|
||||||
return autoupdate(runner)
|
return autoupdate(runner)
|
||||||
elif args.command == 'run':
|
elif args.command == 'run':
|
||||||
return run(runner, args)
|
return run(runner, args)
|
||||||
|
elif args.command == 'identify':
|
||||||
|
return identify(args)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
'Command {0} not implemented.'.format(args.command)
|
'Command {0} not implemented.'.format(args.command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue