From 65dacdb7c84af80cb0db4a0a1474fd884af99781 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Thu, 10 Jun 2021 16:08:37 +0200 Subject: [PATCH] Allow symlinked binaries inside the home dir In case a user has system binaries symlinked to a directory in the home directory, this is no longer ruled out in `exe_exists` to be used by default. --- pre_commit/languages/helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pre_commit/languages/helpers.py b/pre_commit/languages/helpers.py index 29138fd1..032e90c4 100644 --- a/pre_commit/languages/helpers.py +++ b/pre_commit/languages/helpers.py @@ -30,9 +30,10 @@ def exe_exists(exe: str) -> bool: if found is None: # exe exists return False + realpath = os.path.realpath(found) homedir = os.path.expanduser('~') try: - common: Optional[str] = os.path.commonpath((found, homedir)) + common: Optional[str] = os.path.commonpath((realpath, homedir)) except ValueError: # on windows, different drives raises ValueError common = None