1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-26 04:29:21 +00:00
thefuck/thefuck/rules/git_not_command.py
2017-06-05 17:29:42 -04:00

18 lines
593 B
Python

import re
from thefuck.utils import get_all_matched_commands, replace_command
from thefuck.specific.git import git_support
@git_support
def match(command):
return (" is not a git command. See 'git --help'." in command.stderr
and 'The most similar command' in command.stderr)
@git_support
def get_new_command(command):
broken_cmd = re.findall(r"git: '([^']*)' is not a git command",
command.stderr)[0]
matched = get_all_matched_commands(command.stderr, 'The most similar command')
return replace_command(command, broken_cmd, matched)