Skip to content

Improve usability of Remote.ls_remotes's result #1397

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

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

jorio
Copy link
Contributor

@jorio jorio commented Aug 5, 2025

Remote.ls_remotes used to return a dict with str keys, which is inconsistent with how pygit2 generally returns structured results. This PR introduces RemoteHead, a class with fields.

Backwards compatibility with the old-style dict was kept via RemoteHead.__getitem__ which emits a DeprecationWarning.

Also, when the local flag is off, RemoteHead.loid now forwards oid zero (0000000) as returned by libgit2 instead of making it None.


Tangent: I think ls_remotes is a bit of a confusing name. Perhaps something like list_heads or advertised_heads would be more intuitive, but this could be for another PR. What do you think?

@jdavid jdavid merged commit 6caa06d into libgit2:master Aug 5, 2025
8 checks passed
@jdavid
Copy link
Member

jdavid commented Aug 5, 2025

Remote.list_heads() looks good to me, since it wraps git_remote_ls which returns a list of git_remote_head

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

Successfully merging this pull request may close these issues.

2 participants