Skip to content

Fix submodules listing error #818

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 3 commits into from
Jul 20, 2019

Conversation

stsewd
Copy link
Contributor

@stsewd stsewd commented Dec 24, 2018

Fix #279

When the path doesn't exist, gitpython throws an error, this usually happens when the user deletes the submodule directory but not the submodule entry in .gitmodules.

@Byron
Copy link
Member

Byron commented Dec 24, 2018

Thanks a lot for the contribution and the test. I will be happy to merge after some clarification.

Could you have a look at the test that actually wants the ‘InvavalidGitRepository’ exception? It causes travis to fail consistently. Maybe that usecase is now obsolete by the new behaviour, which is when the test can be adjusted to claim that ‘nothing should happen’ if the submodule is invalid.

Maybe that test, however, could also show that the ‘InvalidGitRepository’ error should rather be cought in the spot that interests you in particular, for example, when listing submodules, instead of removing it entirely.

@stsewd
Copy link
Contributor Author

stsewd commented Dec 24, 2018

Sorry I didn't comment yesterday, I was trying to solve that failing test but some tests are not passing locally (master), need to figure out that first.

@stsewd
Copy link
Contributor Author

stsewd commented Dec 24, 2018

Maybe that test, however, could also show that the ‘InvalidGitRepository’ error should rather be cought in the spot that interests you in particular, for example, when listing submodules, instead of removing it entirely.

I'm not following, sorry. Do you mean to keep the exception and passing the failed submodule as an attribute?

Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments were they matter, maybe this helps to understand what I mean. If anything remains unclear, please let me know.

@@ -1184,8 +1184,9 @@ def iter_items(cls, repo, parent_commit='HEAD'):
entry = index.entries[index.entry_key(p, 0)]
sm = Submodule(repo, entry.binsha, entry.mode, entry.path)
except KeyError:
raise InvalidGitRepositoryError(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way for this Exception to stay, just as there is a test that expects this behaviour (see the test-failure on travis).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do that, we wouldn't be able to keep listing the submodules here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stsewd I think all that's left before the merge is to fix the now failing test. It could be changed to now expect to no failure and to see a listing of the existing submodules - if you think there is not too much overlap with the test you added.

@stsewd
Copy link
Contributor Author

stsewd commented Jan 6, 2019

Also, reading the test looks like the code is doing what we want to avoid

# update fails as list_items in such a situations cannot work, as it cannot
# find the entry at the changed path
self.failUnlessRaises(InvalidGitRepositoryError, rm.update, recursive=False)
# move it properly - doesn't work as it its path currently points to an indexentry
# which doesn't exist ( move it to some path, it doesn't matter here )
self.failUnlessRaises(InvalidGitRepositoryError, sm.move, pp)
# reset the path(cache) to where it was, now it works

The tests are expecting to raise an exception if it can't find the correct path of the submodule, while git just list the valid ones.

@codecov-io
Copy link

codecov-io commented Feb 2, 2019

Codecov Report

Merging #818 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #818      +/-   ##
==========================================
+ Coverage   94.67%   94.68%   +<.01%     
==========================================
  Files          59       59              
  Lines        9393     9399       +6     
==========================================
+ Hits         8893     8899       +6     
  Misses        500      500
Impacted Files Coverage Δ
git/objects/submodule/base.py 94.35% <100%> (ø) ⬆️
git/test/test_submodule.py 99.25% <100%> (+0.01%) ⬆️
git/cmd.py 83.83% <0%> (-0.14%) ⬇️
git/test/test_remote.py 97.8% <0%> (-0.02%) ⬇️
git/repo/base.py 95.24% <0%> (ø) ⬆️

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 6971a93...6a235bc. Read the comment docs.

@stsewd
Copy link
Contributor Author

stsewd commented Feb 2, 2019

I just updated the test, sorry for the long wait. Now py37 is failing, but doesn't look related to this change.

@stsewd stsewd force-pushed the fix-submodules-listing branch from 31d99b5 to 6a235bc Compare June 25, 2019 15:10
@stsewd
Copy link
Contributor Author

stsewd commented Jun 25, 2019

@Byron tests are passing now, any change to get this merged? Thank you! Appveyor is failing in master (isn't triggering for this PR I think), though

stsewd added a commit to stsewd/readthedocs.org that referenced this pull request Jul 10, 2019
Currently we show a generic message.

Related: readthedocs#4371

This can be removed when gitpython-developers/GitPython#818
gets merged.
@Byron Byron merged commit e93ffe1 into gitpython-developers:master Jul 20, 2019
@Byron
Copy link
Member

Byron commented Jul 20, 2019

Sorry for the wait, and thanks a lot for the fixes!

@stsewd stsewd deleted the fix-submodules-listing branch July 20, 2019 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Error while listing submodules
3 participants