Skip to content

Commit

Permalink
git_push: Handle command containing force argument (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
gma2th authored and nvbn committed Jul 9, 2018
1 parent a6bb41e commit 5347824
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/rules/test_git_push.py
Expand Up @@ -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
2 changes: 1 addition & 1 deletion thefuck/rules/git_push.py
Expand Up @@ -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))

0 comments on commit 5347824

Please sign in to comment.