Add handler for "is not a git command"

This commit is contained in:
nvbn
2015-04-08 21:20:11 +02:00
parent 9ed022d67f
commit e7b377a310
5 changed files with 55 additions and 2 deletions
+16
View File
@@ -0,0 +1,16 @@
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)
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]*)',
command.stderr)[0]
return command.script.replace(broken_cmd, new_cmd, 1)
+1 -1
View File
@@ -22,4 +22,4 @@ def get_new_command(command, settings):
output)[0]
fixed_name = re.findall(r"Command '([^']*)' from package",
output)[0]
return command.script.replace(broken_name, fixed_name)
return command.script.replace(broken_name, fixed_name, 1)