Skip to content

Commit 2aa8821

Browse files
committed
Added pre-commit.py script
1 parent 6e63d3a commit 2aa8821

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
build
99
dist
1010
*.egg-info
11+
*.iml

pre_commit/run.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
import argparse
3+
4+
5+
def install():
6+
"""Install the pre-commit hook."""
7+
raise NotImplementedError
8+
9+
10+
def uninstall():
11+
"""Uninstall the pre-commit hook."""
12+
raise NotImplementedError
13+
14+
15+
def run_hooks(arguments):
16+
"""Actually run the hooks."""
17+
raise NotImplementedError
18+
19+
20+
def run(argv):
21+
parser = argparse.ArgumentParser()
22+
23+
group = parser.add_mutually_exclusive_group(required=False)
24+
group.add_argument(
25+
'-i', '--install',
26+
action='store_true',
27+
help='Install the pre-commit script.',
28+
)
29+
group.add_argument(
30+
'-u', '--uninstall',
31+
action='store_true',
32+
help='Uninstall the pre-commit script.',
33+
)
34+
35+
args = parser.parse_args(argv)
36+
37+
if args.install:
38+
install()
39+
elif args.uninstall:
40+
uninstall()
41+
else:
42+
run_hooks(args)

scripts/pre-commit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
3+
if __name__ == '__main__':
4+
import sys
5+
6+
from pre_commit.run import run
7+
8+
sys.exit(run(sys.argv[1:]))

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
'argparse',
1010
'simplejson',
1111
],
12+
scripts=[
13+
'scripts/pre-commit.py',
14+
],
1215
)

0 commit comments

Comments
 (0)