Repository navigation
Conversation
git remote -v can produce lines with fewer than 2 space-separated tokens (e.g., a bare "(fetch)" line), causing the list comprehension in git_info() to raise an IndexError. Add a length check before accessing split() results to skip malformed lines gracefully.
TheKevJames
left a comment
There was a problem hiding this comment.
Thanks for submitting this fix!
Do you have an example of a case when git remote -v would provide this output? My understanding was that the output of that command was pretty standardized, so IMO it doesn't make sense to guard against a case that can't really happen. Is there some sort of git version, config flag, remote state, or alternate porcelain involved?
|
The guard does fix the crash it describes. I took the current parser and the patched one and ran both over the same output: Two things I would look at before merging, both about the shape of the fix rather than whether it works. The guard admits one malformed line the parser still mis-reads. That is the same class of bug, one step further in. The One practical note: this was opened in May and that block has moved since. The except clause underneath is now The regression test is worth keeping whichever form the fix takes; it mocks |
Summary
IndexErrorincoveralls/git.pywhengit remote -vproduces malformed lines containing(fetch)with fewer than 2 space-separated tokensline.split()results in the remotes list comprehensionTest plan
pytest tests/test_git_malformed_remote.py -vto verify the bug is fixedpytest tests/ --ignore=tests/git_test.py --ignore=tests/cli_test.py --ignore=tests/api_test.py --ignore=tests/data/to verify no regressions