libgit2 / libgit2/pygit2

`pygit2.remote.RemoteCollection` should implement `__contains__()` to match with valid remote names

Open
#1,080 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

As it stands the following happens

>>> import os, pygit2
>>> r = pygit2.Repository(os.getcwd())
>>> 'origin' in r.remotes
False

Whereas looping over the names results in a match

>>> import os, pygit2
>>> r = pygit2.Repository(os.getcwd())
>>> 'origin' in [remote.name for remote in r.remotes]
True

This behavior seems unpythonic since remote.RemoteCollection implements __getitem__() and in doesn't match with a valid key in the collection.

If this change makes sense I can to try fix it when I have time, lmk!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at pygit2.remote.RemoteCollection and inspect its existing getitem() behavior. Reproduce the issue's 'origin' membership example, then verify that membership matches valid remote names and rejects invalid ones after the collection supports contains().

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.