diff options
| author | Simeon Simeonov | 2018-09-13 12:47:54 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2018-09-13 12:47:54 +0200 |
| commit | c0259c87a7a2343a21634e038a50ff549bc975e5 (patch) | |
| tree | ca79b7780b55719d9ab529f428047de2df063c8e | |
Initial commit
| -rwxr-xr-x | pygitchecker.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pygitchecker.py b/pygitchecker.py new file mode 100755 index 0000000..29c9167 --- /dev/null +++ b/pygitchecker.py | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | |||
| 3 | import argparse | ||
| 4 | import sys | ||
| 5 | |||
| 6 | import gitapi | ||
| 7 | import pep8 | ||
| 8 | |||
| 9 | |||
| 10 | if __name__ == '__main__': | ||
| 11 | parser = argparse.ArgumentParser( | ||
| 12 | description='The following options are available') | ||
| 13 | parser.add_argument( | ||
| 14 | 'repo_path', | ||
| 15 | metavar='REPO', | ||
| 16 | default='.', | ||
| 17 | type=str, | ||
| 18 | help='Git repo path (default: cwd)') | ||
| 19 | parser.add_argument( | ||
| 20 | '--disable-pep8-checks', | ||
| 21 | action='store_true', | ||
| 22 | dest='disable_pep8', | ||
| 23 | default=False, | ||
| 24 | help='Disable pep8 checks') | ||
| 25 | args = parser.parse_args() | ||
| 26 | git_repo = gitapi.Repo(args.repo_path) | ||
| 27 | status = git_repo.git_status() | ||
| 28 | if 'M' not in status: | ||
| 29 | print('No modifications') | ||
| 30 | sys.exit(0) | ||
| 31 | remarks = False | ||
| 32 | for mfile in status.get('M'): | ||
| 33 | if not args.disable_pep8: | ||
| 34 | checker = pep8.Checker(mfile) | ||
| 35 | if checker.check_all(): | ||
| 36 | remarks = True | ||
| 37 | if remarks: | ||
| 38 | print('Done!') | ||
