From 4d89b3499e2e0f87563a2bcd191c8aed67c46249 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 19 Aug 2016 22:08:30 +0100 Subject: [PATCH 1/3] Preserve args for git_push --- thefuck/rules/git_push.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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) From 612c393ec4d964fb933ebf5b8f957ae573ae65ba Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 19 Aug 2016 22:19:09 +0100 Subject: [PATCH 2/3] Check git_push matches without specifying a branch --- tests/rules/test_git_push.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/rules/test_git_push.py b/tests/rules/test_git_push.py index 65b210a1..4d857516 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)) From 5df350254e966007f80f7a14fde29a8c93316bb3 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Fri, 19 Aug 2016 22:24:02 +0100 Subject: [PATCH 3/3] Check arguments are preserved in git_push --- tests/rules/test_git_push.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/rules/test_git_push.py b/tests/rules/test_git_push.py index 4d857516..7531472d 100644 --- a/tests/rules/test_git_push.py +++ b/tests/rules/test_git_push.py @@ -23,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"