Skip to content

Commit

Permalink
#579: Ignore commands of len 1 in missing_space_before_subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Aug 1, 2021
1 parent 8bebce3 commit 7f34427
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions tests/rules/test_missing_space_before_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
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, ''))

Expand All @@ -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
2 changes: 1 addition & 1 deletion thefuck/rules/missing_space_before_subcommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@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


Expand Down

0 comments on commit 7f34427

Please # to comment.