git_push: Escape single quote in branch names (#760)

Parameterize test output fixture.

Check for 'push' in command.script_parts than anywhere in command.script.
This commit is contained in:
David Hart
2018-01-04 16:40:01 +00:00
committed by Joseph Frazier
parent a696461cd3
commit b62bb90a0d
2 changed files with 43 additions and 30 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ from thefuck.specific.git import git_support
@git_support
def match(command):
return ('push' in command.script
return ('push' in command.script_parts
and 'set-upstream' in command.output)
@@ -39,6 +39,6 @@ def get_new_command(command):
while len(command_parts) > push_idx and command_parts[len(command_parts) - 1][0] != '-':
command_parts.pop(len(command_parts) - 1)
arguments = re.findall(r'git push (.*)', command.output)[0].strip()
arguments = re.findall(r'git push (.*)', command.output)[0].replace("'", r"\'").strip()
return replace_argument(" ".join(command_parts), 'push',
'push {}'.format(arguments))