mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-18 20:11:17 +00:00
git_push: Don't add duplicate remote/branch name (#745)
This fixes https://github.com/nvbn/thefuck/issues/740
This commit is contained in:
parent
f966ecd4f5
commit
4ea02a3153
@ -23,6 +23,8 @@ def test_match(output):
|
||||
def test_get_new_command(output):
|
||||
assert get_new_command(Command('git push', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push master', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push -u', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push -u origin', output))\
|
||||
|
@ -32,6 +32,10 @@ def get_new_command(command):
|
||||
# In case of `git push -u` we don't have next argument:
|
||||
if len(command_parts) > upstream_option_index:
|
||||
command_parts.pop(upstream_option_index)
|
||||
# If the only argument is the remote/branch, remove it.
|
||||
# git's suggestion includes it, so it won't be lost, and we would duplicate it otherwise.
|
||||
elif len(command_parts) is 3 and command_parts[2][0] != '-':
|
||||
command_parts.pop(2)
|
||||
|
||||
arguments = re.findall(r'git push (.*)', command.output)[0].strip()
|
||||
return replace_argument(" ".join(command_parts), 'push',
|
||||
|
Loading…
x
Reference in New Issue
Block a user