forked from sebdah/git-pylint-commit-hook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-pylint-commit-hook
executable file
·72 lines (59 loc) · 1.83 KB
/
git-pylint-commit-hook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
"""
Git pre-commit hook for checking Python code quality. The hook requires pylint
to check the code quality.
AUTHOR:
Sebastian Dahlgren <[email protected]>
LICENSE:
Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
"""
VERSION = '2.0.8'
import argparse
import sys
from git_pylint_commit_hook import commit_hook
def main():
""" Main function handling configuration files etc """
parser = argparse.ArgumentParser(
description='Git pylint commit hook')
parser.add_argument(
'--limit',
default=8.0,
type=float,
help=(
'Score limit, files with a lower score will stop the '
'commit. Default: 8.0'))
parser.add_argument(
'--pylint',
default='pylint',
help='Path to pylint executable. Default: pylint')
parser.add_argument(
'--pylintrc',
default='.pylintrc',
help=(
'Path to pylintrc file. Options in the pylintrc will '
'override the command line parameters. Default: .pylintrc'))
parser.add_argument(
'--pylint-params',
help='Custom pylint parameters to add to the pylint command')
parser.add_argument(
'--suppress-report',
action='store_true',
help='Suppress report output if pylint fails')
parser.add_argument(
'--version',
action='store_true',
help='Print current version number')
args = parser.parse_args()
if args.version:
print('git-pylint-commit-hook version {}'.format(VERSION))
sys.exit(0)
result = commit_hook.check_repo(
args.limit, args.pylint, args.pylintrc, args.pylint_params, args.suppress_report)
if result:
sys.exit(0)
sys.exit(1)
if __name__ == '__main__':
main()
sys.exit(0)
sys.exit(1)