mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 14:48:49 +00:00
Don't add duplicate remote/branch name
This commit is contained in:
parent
f966ecd4f5
commit
2091aacbd5
@ -27,7 +27,13 @@ def test_get_new_command(output):
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push -u origin', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push origin', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push --set-upstream origin', output))\
|
||||
== "git push --set-upstream origin master"
|
||||
assert get_new_command(Command('git push --quiet', output))\
|
||||
== "git push --set-upstream origin master --quiet"
|
||||
assert get_new_command(Command('git push --quiet origin', output))\
|
||||
== "git push --set-upstream origin master --quiet"
|
||||
assert get_new_command(Command('git -c test=test push --quiet origin', output))\
|
||||
== "git -c test=test push --set-upstream origin master --quiet"
|
@ -32,6 +32,11 @@ 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)
|
||||
elif len(command_parts) > 2:
|
||||
# the last permitted options are the repository and refspec; git's suggestion
|
||||
# include them, so they won't be lost, but would be duplicated otherwise.
|
||||
while len(command_parts) > 2 and command_parts[len(command_parts) - 1][0] != '-':
|
||||
command_parts.pop(len(command_parts) - 1)
|
||||
|
||||
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