diff --git a/tests/rules/test_git_push.py b/tests/rules/test_git_push.py index b6aa7c60..7b979292 100644 --- a/tests/rules/test_git_push.py +++ b/tests/rules/test_git_push.py @@ -66,6 +66,10 @@ def test_not_match(output, script, branch_name): ('git -c test=test push --quiet origin', 'master', 'git -c test=test push --set-upstream origin master --quiet'), ('git push', "test's", - "git push --set-upstream origin test\\'s")]) + "git push --set-upstream origin test\\'s"), + ('git push --force', 'master', + 'git push --set-upstream origin master --force'), + ('git push --force-with-lease', 'master', + 'git push --set-upstream origin master --force-with-lease')]) def test_get_new_command(output, script, branch_name, new_command): assert get_new_command(Command(script, output)) == new_command diff --git a/thefuck/rules/git_push.py b/thefuck/rules/git_push.py index cccee67c..018ff152 100644 --- a/thefuck/rules/git_push.py +++ b/thefuck/rules/git_push.py @@ -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].replace("'", r"\'").strip() + arguments = re.findall(r'git push (.*)', command.output)[-1].replace("'", r"\'").strip() return replace_argument(" ".join(command_parts), 'push', 'push {}'.format(arguments))