Add git_rm_staged rule for removing locally staged changes

It would be nice if `thefuck` could help me `git rm` a file I had
already staged. This rule, adapted from `git_rm_local_modifications`,
does that.
This commit is contained in:
Joseph Frazier
2017-02-26 19:16:15 -05:00
parent 91c27e1a62
commit 42ec01dab1
3 changed files with 48 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
from thefuck.specific.git import git_support
@git_support
def match(command):
return (' rm ' in command.script and
'error: the following file has changes staged in the index' in command.stderr and
'use --cached to keep the file, or -f to force removal' in command.stderr)
@git_support
def get_new_command(command):
command_parts = command.script_parts[:]
index = command_parts.index('rm') + 1
command_parts.insert(index, '--cached')
command_list = [u' '.join(command_parts)]
command_parts[index] = '-f'
command_list.append(u' '.join(command_parts))
return command_list