mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 00:14:46 +00:00
Add lazy option to the git_hook.
This commit is contained in:
parent
ada8d325ca
commit
01471f885d
1 changed files with 6 additions and 2 deletions
|
|
@ -140,14 +140,18 @@ def run(command):
|
||||||
[line.strip() for line in p.stderr.readlines()])
|
[line.strip() for line in p.stderr.readlines()])
|
||||||
|
|
||||||
|
|
||||||
def git_hook(complexity=-1, strict=False, ignore=None):
|
def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
|
||||||
_initpep8()
|
_initpep8()
|
||||||
if ignore:
|
if ignore:
|
||||||
pep8.options.ignore = ignore
|
pep8.options.ignore = ignore
|
||||||
|
|
||||||
warnings = 0
|
warnings = 0
|
||||||
|
|
||||||
_, files_modified, _ = run("git diff-index --cached --name-only HEAD")
|
gitcmd = "git diff-index --cached --name-only HEAD"
|
||||||
|
if lazy:
|
||||||
|
gitcmd = gitcmd.replace('--cached ', '')
|
||||||
|
|
||||||
|
_, files_modified, _ = run(gitcmd)
|
||||||
for filename in files_modified:
|
for filename in files_modified:
|
||||||
ext = os.path.splitext(filename)[-1]
|
ext = os.path.splitext(filename)[-1]
|
||||||
if ext != '.py':
|
if ext != '.py':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue