Add the git_fix_stash rule

This commit is contained in:
mcarton
2015-07-22 23:16:12 +02:00
parent ab1cd665cd
commit e4da8a2e5a
3 changed files with 72 additions and 7 deletions
+33
View File
@@ -0,0 +1,33 @@
from thefuck import utils
@utils.git_support
def match(command, settings):
return (command.script.split()[1] == 'stash'
and 'usage:' in command.stderr)
# git's output here is too complicated to be parsed (see the test file)
stash_commands = (
'apply',
'branch',
'clear',
'drop',
'list',
'pop',
'save',
'show',
)
@utils.git_support
def get_new_command(command, settings):
stash_cmd = command.script.split()[2]
fixed = utils.get_closest(stash_cmd, stash_commands, fallback_to_first=False)
if fixed is not None:
return command.script.replace(stash_cmd, fixed)
else:
cmd = command.script.split()
cmd.insert(2, 'save')
return ' '.join(cmd)