Skip to content

git.remote.Remote.set_url does not update self.url #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dmtucker opened this issue Apr 5, 2022 · 3 comments
Open

git.remote.Remote.set_url does not update self.url #1422

dmtucker opened this issue Apr 5, 2022 · 3 comments

Comments

@dmtucker
Copy link

dmtucker commented Apr 5, 2022

Python 3.10.1 (main, Dec 12 2021, 12:17:52) [GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import git
>>> git.__version__
'3.1.27'
>>> repo = git.Repo.init(".")
>>> remote = repo.create_remote("name", "url")
>>> remote.set_url("newurl", old_url=remote.url)
<git.Remote "name">
>>> remote.url
'url'
>>> repo.remote(remote.name).url
'newurl'
@dmtucker
Copy link
Author

dmtucker commented Apr 5, 2022

It's also a bit unexpected that Remote.__eq__ does not consider url:

>>> remote == repo.remote(remote.name)
True

@Byron
Copy link
Member

Byron commented Apr 5, 2022

Thanks a lot for letting me know. Help with the fix would definitely be appreciated.

@deroshkin
Copy link

I played around a bit with this bug, and it's trickier than I first thought.

repo = git.Repo.init('.')
remote = repo.create_remote('name', 'url')
print(f'Remote url before set_url: {remote.url}')
remote.set_url('newurl', old_url='url')
print(f'Remote url after set_url: {remote.url}')

prints

Remote url before set_url: url
Remote url after set_url: url

but

repo = git.Repo.init('.')
remote = repo.create_remote('name', 'url')
remote.set_url('newurl', old_url='url')
print(f'Remote url after set_url without an earlier call: {remote.url}')

prints

Remote url after set_url without an earlier call: newurl

This is probably related to the caching of the _config_reader output, but I haven't dug into that yet. In debugging the calls, I also noticed that the Remote.url parameter is never actually given a value, and all access to it is only through the __getattr__ interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants