summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-12-21 01:25:06 +0000
committerIan Cordasco <graffatcolmingov@gmail.com>2016-12-21 01:25:06 +0000
commit4bd79981625afb6e995fb83940e0f21741a3d8d4 (patch)
tree884b33990df9f323c9342f73052cebe65ad54b0a /src
parent85c495b01283ab036ef11e755153e5f0acc4d8c7 (diff)
parentd6b1baf8af69e37f2eb15116952eddd18995847f (diff)
downloadflake8-4bd79981625afb6e995fb83940e0f21741a3d8d4.tar.gz
Merge branch 'bug/244' into 'master'
Display the local paths from the git hook Instead of displaying the path to the temporary directory, as we always have, it's been requested that we instead display the path to the file that was copied to the temporary directory. Closes #244 See merge request !154
Diffstat (limited to 'src')
-rw-r--r--src/flake8/main/git.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/flake8/main/git.py b/src/flake8/main/git.py
index 5eae0d0..31404d8 100644
--- a/src/flake8/main/git.py
+++ b/src/flake8/main/git.py
@@ -6,6 +6,7 @@
"""
import contextlib
import os
+import os.path
import shutil
import stat
import subprocess
@@ -46,6 +47,7 @@ def hook(lazy=False, strict=False):
app.options._running_from_vcs = True
app.run_checks(filepaths)
+ update_paths(app.file_checker_manager, tempdir)
app.report_errors()
if strict:
return app.result_count
@@ -204,6 +206,16 @@ def update_excludes(exclude_list, temporary_directory_path):
]
+def update_paths(checker_manager, temp_prefix):
+ temp_prefix_length = len(temp_prefix)
+ for checker in checker_manager.checkers:
+ filename = checker.display_name
+ if filename.startswith(temp_prefix):
+ checker.display_name = os.path.relpath(
+ filename[temp_prefix_length:]
+ )
+
+
_HOOK_TEMPLATE = """#!{executable}
import os
import sys