1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

#579: Ignore commands of len 1 in missing_space_before_subcommand

This commit is contained in:
Pablo Santiago Blum de Aguiar 2021-07-29 23:54:51 +02:00 committed by Pablo Aguiar
parent 8bebce331e
commit 7f3442747e
2 changed files with 5 additions and 4 deletions

View File

@ -8,11 +8,11 @@ from thefuck.types import Command
def all_executables(mocker):
return mocker.patch(
'thefuck.rules.missing_space_before_subcommand.get_all_executables',
return_value=['git', 'ls', 'npm'])
return_value=['git', 'ls', 'npm', 'w', 'watch'])
@pytest.mark.parametrize('script', [
'gitbranch', 'ls-la', 'npminstall'])
'gitbranch', 'ls-la', 'npminstall', 'watchls'])
def test_match(script):
assert match(Command(script, ''))
@ -25,6 +25,7 @@ def test_not_match(script):
@pytest.mark.parametrize('script, result', [
('gitbranch', 'git branch'),
('ls-la', 'ls -la'),
('npminstall webpack', 'npm install webpack')])
('npminstall webpack', 'npm install webpack'),
('watchls', 'watch ls')])
def test_get_new_command(script, result):
assert get_new_command(Command(script, '')) == result

View File

@ -4,7 +4,7 @@ from thefuck.utils import get_all_executables, memoize
@memoize
def _get_executable(script_part):
for executable in get_all_executables():
if script_part.startswith(executable):
if len(executable) > 1 and script_part.startswith(executable):
return executable