summaryrefslogtreecommitdiff
path: root/pygitchecker.py
blob: 29c9167b9b655cd02678691edc0b0bf986207643 (plain)
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
#!/usr/bin/env python3

import argparse
import sys

import gitapi
import pep8


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='The following options are available')
    parser.add_argument(
        'repo_path',
        metavar='REPO',
        default='.',
        type=str,
        help='Git repo path (default: cwd)')
    parser.add_argument(
        '--disable-pep8-checks',
        action='store_true',
        dest='disable_pep8',
        default=False,
        help='Disable pep8 checks')
    args = parser.parse_args()
    git_repo = gitapi.Repo(args.repo_path)
    status = git_repo.git_status()
    if 'M' not in status:
        print('No modifications')
        sys.exit(0)
    remarks = False
    for mfile in status.get('M'):
        if not args.disable_pep8:
            checker = pep8.Checker(mfile)
            if checker.check_all():
                remarks = True
    if remarks:
        print('Done!')