mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 12:16:53 +00:00
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
This commit is contained in:
parent
85c495b012
commit
d6b1baf8af
2 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue