mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
#579: Ignore commands of len 1 in missing_space_before_subcommand
This commit is contained in:
parent
8bebce331e
commit
7f3442747e
@ -8,11 +8,11 @@ from thefuck.types import Command
|
|||||||
def all_executables(mocker):
|
def all_executables(mocker):
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
'thefuck.rules.missing_space_before_subcommand.get_all_executables',
|
'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', [
|
@pytest.mark.parametrize('script', [
|
||||||
'gitbranch', 'ls-la', 'npminstall'])
|
'gitbranch', 'ls-la', 'npminstall', 'watchls'])
|
||||||
def test_match(script):
|
def test_match(script):
|
||||||
assert match(Command(script, ''))
|
assert match(Command(script, ''))
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ def test_not_match(script):
|
|||||||
@pytest.mark.parametrize('script, result', [
|
@pytest.mark.parametrize('script, result', [
|
||||||
('gitbranch', 'git branch'),
|
('gitbranch', 'git branch'),
|
||||||
('ls-la', 'ls -la'),
|
('ls-la', 'ls -la'),
|
||||||
('npminstall webpack', 'npm install webpack')])
|
('npminstall webpack', 'npm install webpack'),
|
||||||
|
('watchls', 'watch ls')])
|
||||||
def test_get_new_command(script, result):
|
def test_get_new_command(script, result):
|
||||||
assert get_new_command(Command(script, '')) == result
|
assert get_new_command(Command(script, '')) == result
|
||||||
|
@ -4,7 +4,7 @@ from thefuck.utils import get_all_executables, memoize
|
|||||||
@memoize
|
@memoize
|
||||||
def _get_executable(script_part):
|
def _get_executable(script_part):
|
||||||
for executable in get_all_executables():
|
for executable in get_all_executables():
|
||||||
if script_part.startswith(executable):
|
if len(executable) > 1 and script_part.startswith(executable):
|
||||||
return executable
|
return executable
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user