GitPython icon indicating copy to clipboard operation
GitPython copied to clipboard

git.remote.Remote.set_url does not add new URL by default

Open deroshkin opened this issue 3 years ago • 2 comments

The documentation for Remote.set_url states that new_url is "add[ed] as an extra remote URL" unless old_url parameter is passed. However, the way it is currently written, the method actually replaces the existing URL instead of adding a new one.

repo = git.Repo.init('.')
remote = repo.create_remote('name', 'url')
remote.set_url('newurl')
for url in repo.remote('name').urls::
    print(url)

actual output:

newurl

expected:

url
newurl

deroshkin avatar May 25 '22 16:05 deroshkin

I have a patch ready, but I'll hold off submitting a pull request since the current TestRemote.test_multiple_urls in test_remote.py actually depends on the current behavior, so I'm not sure whether to change the set_url docstring or the behavior.

deroshkin avatar May 25 '22 16:05 deroshkin

Here I recommend improving the documentation to clarify what it does while considering the addition of another method to exhibit the new behaviour of actually adding another URL on top of the existing one as multi-value.

Byron avatar May 26 '22 01:05 Byron