Skip to content

Fix error on comparing git.Remote #839

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
Sep 28, 2019
Merged

Fix error on comparing git.Remote #839

merged 2 commits into from
Sep 28, 2019

Conversation

tzing
Copy link
Contributor

@tzing tzing commented Feb 7, 2019

We can't use 'foo' in repo.remotes syntax in current version, but 'foo' in repo.refs works fine.

It raises AttributeError before it runs full name search:

In [2]: r = git.Repo('.')

In [3]: 'origin' in r.remotes
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-800621fb1c9b> in <module>
----> 1 'origin' in r.remotes

~/Projects/GitPython/git/util.py in __contains__(self, attr)
    865     def __contains__(self, attr):
    866         # first try identity match for performance
--> 867         rval = list.__contains__(self, attr)
    868         if rval:
    869             return rval

~/Projects/GitPython/git/remote.py in __eq__(self, other)
    449
    450     def __eq__(self, other):
--> 451         return self.name == other.name
    452
    453     def __ne__(self, other):

AttributeError: 'str' object has no attribute 'name'

fix it add type check before it compares name.

@codecov-io
Copy link

Codecov Report

Merging #839 into master will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #839      +/-   ##
==========================================
- Coverage   94.79%   94.67%   -0.13%     
==========================================
  Files          59       59              
  Lines        9603     9386     -217     
==========================================
- Hits         9103     8886     -217     
  Misses        500      500
Impacted Files Coverage Δ
git/objects/tree.py 59.64% <0%> (-0.93%) ⬇️
git/index/util.py 90.69% <0%> (-0.61%) ⬇️
git/index/typ.py 96.82% <0%> (-0.58%) ⬇️
git/refs/log.py 93.84% <0%> (-0.53%) ⬇️
git/objects/base.py 95.83% <0%> (-0.33%) ⬇️
git/refs/tag.py 96.66% <0%> (-0.31%) ⬇️
git/test/lib/helper.py 91.86% <0%> (-0.28%) ⬇️
git/refs/reference.py 95.74% <0%> (-0.26%) ⬇️
git/objects/commit.py 91.59% <0%> (-0.25%) ⬇️
git/cmd.py 83.83% <0%> (-0.18%) ⬇️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f66e25...036a531. Read the comment docs.

@Byron Byron added this to the v3.0.3 - Bugfixes milestone Sep 28, 2019
@Byron
Copy link
Member

Byron commented Sep 28, 2019

My apologies for the late reply - I must have missed this PR :(!
Thanks a lot for your contribution!

@Byron Byron merged commit 9121f62 into gitpython-developers:master Sep 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants