mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
Merge pull request #1669 from pre-commit/not_a_shim_when_home_is_slash
allow default language_version of system when homedir is /
This commit is contained in:
commit
8fb7365a61
2 changed files with 14 additions and 2 deletions
|
|
@ -37,8 +37,14 @@ def exe_exists(exe: str) -> bool:
|
||||||
common = None
|
common = None
|
||||||
|
|
||||||
return (
|
return (
|
||||||
not SHIMS_RE.search(found) and # it is not in a /shims/ directory
|
# it is not in a /shims/ directory
|
||||||
common != homedir # it is not in the home directory
|
not SHIMS_RE.search(found) and
|
||||||
|
(
|
||||||
|
# the homedir is / (docker, service user, etc.)
|
||||||
|
os.path.dirname(homedir) == homedir or
|
||||||
|
# the exe is not contained in the home directory
|
||||||
|
common != homedir
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,12 @@ def test_exe_exists_commonpath_raises_ValueError(find_exe_mck, homedir_mck):
|
||||||
assert helpers.exe_exists('ruby') is True
|
assert helpers.exe_exists('ruby') is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_exe_exists_true_when_homedir_is_slash(find_exe_mck):
|
||||||
|
find_exe_mck.return_value = os.path.normpath('/usr/bin/ruby')
|
||||||
|
with mock.patch.object(os.path, 'expanduser', return_value=os.sep):
|
||||||
|
assert helpers.exe_exists('ruby') is True
|
||||||
|
|
||||||
|
|
||||||
def test_basic_get_default_version():
|
def test_basic_get_default_version():
|
||||||
assert helpers.basic_get_default_version() == C.DEFAULT
|
assert helpers.basic_get_default_version() == C.DEFAULT
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue