mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-20 01:24:42 +04:00
Added pre-commit.py script
This commit is contained in:
parent
6e63d3a4a2
commit
2aa8821b70
4 changed files with 54 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,3 +8,4 @@
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
*.egg-info
|
*.egg-info
|
||||||
|
*.iml
|
||||||
|
|
|
||||||
42
pre_commit/run.py
Normal file
42
pre_commit/run.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
def install():
|
||||||
|
"""Install the pre-commit hook."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def uninstall():
|
||||||
|
"""Uninstall the pre-commit hook."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def run_hooks(arguments):
|
||||||
|
"""Actually run the hooks."""
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def run(argv):
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
|
group = parser.add_mutually_exclusive_group(required=False)
|
||||||
|
group.add_argument(
|
||||||
|
'-i', '--install',
|
||||||
|
action='store_true',
|
||||||
|
help='Install the pre-commit script.',
|
||||||
|
)
|
||||||
|
group.add_argument(
|
||||||
|
'-u', '--uninstall',
|
||||||
|
action='store_true',
|
||||||
|
help='Uninstall the pre-commit script.',
|
||||||
|
)
|
||||||
|
|
||||||
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
|
if args.install:
|
||||||
|
install()
|
||||||
|
elif args.uninstall:
|
||||||
|
uninstall()
|
||||||
|
else:
|
||||||
|
run_hooks(args)
|
||||||
8
scripts/pre-commit.py
Executable file
8
scripts/pre-commit.py
Executable file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from pre_commit.run import run
|
||||||
|
|
||||||
|
sys.exit(run(sys.argv[1:]))
|
||||||
3
setup.py
3
setup.py
|
|
@ -9,4 +9,7 @@ setup(
|
||||||
'argparse',
|
'argparse',
|
||||||
'simplejson',
|
'simplejson',
|
||||||
],
|
],
|
||||||
|
scripts=[
|
||||||
|
'scripts/pre-commit.py',
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue