From 01471f885d2cf9dc5d0adf04c13e2c583b12b8df Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 8 Nov 2012 13:44:17 -0500 Subject: [PATCH] Add lazy option to the git_hook. --- flake8/run.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flake8/run.py b/flake8/run.py index 32249e5..ab4a033 100644 --- a/flake8/run.py +++ b/flake8/run.py @@ -140,14 +140,18 @@ def run(command): [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() if ignore: pep8.options.ignore = ignore 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: ext = os.path.splitext(filename)[-1] if ext != '.py':