diff --git a/tests/rules/test_git_push.py b/tests/rules/test_git_push.py index 65b210a1..7531472d 100644 --- a/tests/rules/test_git_push.py +++ b/tests/rules/test_git_push.py @@ -14,6 +14,7 @@ To push the current branch and set the remote as upstream, use def test_match(stderr): + assert match(Command('git push', stderr=stderr)) assert match(Command('git push master', stderr=stderr)) assert not match(Command('git push master')) assert not match(Command('ls', stderr=stderr)) @@ -22,3 +23,5 @@ def test_match(stderr): def test_get_new_command(stderr): assert get_new_command(Command('git push', stderr=stderr))\ == "git push --set-upstream origin master" + assert get_new_command(Command('git push --quiet', stderr=stderr))\ + == "git push --set-upstream origin master --quiet" diff --git a/thefuck/rules/git_push.py b/thefuck/rules/git_push.py index 22237105..86a2ea5a 100644 --- a/thefuck/rules/git_push.py +++ b/thefuck/rules/git_push.py @@ -1,3 +1,4 @@ +from thefuck.utils import replace_argument from thefuck.specific.git import git_support @@ -9,4 +10,5 @@ def match(command): @git_support def get_new_command(command): - return command.stderr.split('\n')[-3].strip() + push_upstream = command.stderr.split('\n')[-3].strip().partition('git ')[2] + return replace_argument(command.script, 'push', push_upstream)