summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-11-13 14:48:18 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2016-11-13 14:48:18 -0600
commit2197c2ea1561e7dca595d82d30d4e5dceada2f07 (patch)
tree5bc50ef5781cf9aee3bb8a01411d6c4e775cff16
parent3fecbe177d66cf34951cda6e1a86d92e5537e1ce (diff)
downloadflake8-2197c2ea1561e7dca595d82d30d4e5dceada2f07.tar.gz
Correct exclude paths in git hook
When running the git hook, even though the appropriate config file is found and processed, the exclude patterns and paths were not being corrected to account for the temporary directory that we copy the files into. Related-to #223
-rw-r--r--src/flake8/main/git.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/flake8/main/git.py b/src/flake8/main/git.py
index 3f9689f..096fed6 100644
--- a/src/flake8/main/git.py
+++ b/src/flake8/main/git.py
@@ -42,6 +42,7 @@ def hook(lazy=False, strict=False):
with make_temporary_directory() as tempdir:
filepaths = list(copy_indexed_files_to(tempdir, lazy))
app.initialize(['.'])
+ app.options.exclude = update_excludes(app.options.exclude, tempdir)
app.run_checks(filepaths)
app.report_errors()
@@ -194,6 +195,14 @@ def config_for(parameter):
return value.lower() in defaults.TRUTHY_VALUES
+def update_excludes(exclude_list, temporary_directory_path):
+ return [
+ (temporary_directory_path + pattern)
+ if os.path.isabs(pattern) else pattern
+ for pattern in exclude_list
+ ]
+
+
_HOOK_TEMPLATE = """#!{executable}
import os
import sys