diff --git a/setup.py b/setup.py index b211e705..f6ec1878 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup(name='thefuck', - version=1.13, + version=1.14, description="Magnificent app which corrects your previous console command", author='Vladimir Iakovlev', author_email='nvbn.rm@gmail.com', diff --git a/tests/rules/test_git_not_command.py b/tests/rules/test_git_not_command.py index 71b1012d..657953fc 100644 --- a/tests/rules/test_git_not_command.py +++ b/tests/rules/test_git_not_command.py @@ -12,17 +12,33 @@ branch """ +@pytest.fixture +def git_not_command_one_of_this(): + return """git: 'st' is not a git command. See 'git --help'. + +Did you mean one of these? +status +reset +stage +stash +stats +""" + + @pytest.fixture def git_command(): return "* master" -def test_match(git_not_command, git_command): +def test_match(git_not_command, git_command, git_not_command_one_of_this): assert match(Command('git brnch', '', git_not_command), None) + assert match(Command('git st', '', git_not_command_one_of_this), None) assert not match(Command('ls brnch', '', git_not_command), None) assert not match(Command('git branch', '', git_command), None) -def test_get_new_command(git_not_command): +def test_get_new_command(git_not_command, git_not_command_one_of_this): assert get_new_command(Command('git brnch', '', git_not_command), None)\ == 'git branch' + assert get_new_command( + Command('git st', '', git_not_command_one_of_this), None) == 'git status' diff --git a/thefuck/rules/git_not_command.py b/thefuck/rules/git_not_command.py index ba7aced7..4e9790b6 100644 --- a/thefuck/rules/git_not_command.py +++ b/thefuck/rules/git_not_command.py @@ -4,13 +4,13 @@ import re def match(command, settings): return ('git' in command.script and " is not a git command. See 'git --help'." in command.stderr - and 'Did you mean this?' in command.stderr) + and 'Did you mean' in command.stderr) def get_new_command(command, settings): broken_cmd = re.findall(r"git: '([^']*)' is not a git command", command.stderr)[0] - new_cmd = re.findall(r'Did you mean this\?\n\s*([^\n]*)', + new_cmd = re.findall(r'Did you mean[^\n]*\n\s*([^\n]*)', command.stderr)[0] return command.script.replace(broken_cmd, new_cmd, 1)