aspiers / git-deps

git commit dependency analysis tool
GNU General Public License v2.0
299 stars 47 forks source link

Submodules not treated properly leading to crash/failure #107

Open fuulish opened 3 years ago

fuulish commented 3 years ago

When commits include submodules, the respective dependencies cannot be resolved. The submodule commit OID contains the hash of the submodule commit. This commit is not present in the instance of the parent repo. At the following place in the tree_lookup, this will lead to a KeyError being thrown:

https://github.com/aspiers/git-deps/blob/5dd7f4c4b6d4d771c5b6866b8256eb1bad632843/git_deps/detector.py#L344

A simple fix would be to check first whether the OID is contained in the repo and simply return None if it's not, something like this: https://github.com/fuulish/git-deps/commit/1c55add39712b77994a95fb0a68745a94cccde79

This ignores submodule dependencies. However, submodule-related changes are linearly dependent on their respective parent changes. Hence, a proper solution should include the actual dependency chain. One suggestion could be like the following: https://github.com/fuulish/git-deps/commit/2fd1455635a1f0882dd6e6733b6f6850155e7ce9

Let me know what you think.