mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-19 17:18:42 +00:00
allow for the mispelling of git and the command
This commit is contained in:
parent
33a87502cd
commit
2d4a23df0b
16
thefuck/fix_git_and_command_misspell.py
Normal file
16
thefuck/fix_git_and_command_misspell.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from difflib import get_close_matches
|
||||||
|
|
||||||
|
|
||||||
|
def fix_git_command(git_command):
|
||||||
|
git_possible = ['clone', 'init', 'add', 'mv', 'reset', 'rm', 'bisect',
|
||||||
|
'grep', 'log', 'show', 'status', 'branch', 'checkout',
|
||||||
|
'commit', 'diff', 'merge', 'rebase', 'tag', 'fetch',
|
||||||
|
'pull', 'push']
|
||||||
|
if git_command not in git_possible[0]:
|
||||||
|
close_match = get_close_matches(git_command, git_possible)
|
||||||
|
if len(close_match) > 0:
|
||||||
|
return close_match[0]
|
||||||
|
else:
|
||||||
|
return git_command
|
||||||
|
else:
|
||||||
|
return git_command
|
@ -2,6 +2,7 @@ from difflib import get_close_matches
|
|||||||
from thefuck.utils import get_all_executables, \
|
from thefuck.utils import get_all_executables, \
|
||||||
get_valid_history_without_current, get_closest, which
|
get_valid_history_without_current, get_closest, which
|
||||||
from thefuck.specific.sudo import sudo_support
|
from thefuck.specific.sudo import sudo_support
|
||||||
|
from thefuck.fix_git_and_command_misspell import fix_git_command
|
||||||
|
|
||||||
|
|
||||||
@sudo_support
|
@sudo_support
|
||||||
@ -35,6 +36,9 @@ def get_new_command(command):
|
|||||||
get_all_executables())
|
get_all_executables())
|
||||||
if cmd not in new_cmds]
|
if cmd not in new_cmds]
|
||||||
|
|
||||||
|
if 'git' in new_cmds and len(command.script_parts) > 1:
|
||||||
|
command.script_parts[1] = fix_git_command(command.script_parts[1])
|
||||||
|
|
||||||
return [' '.join([new_command] + command.script_parts[1:])
|
return [' '.join([new_command] + command.script_parts[1:])
|
||||||
for new_command in new_cmds]
|
for new_command in new_cmds]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user