Skip to content

'Tree' object has no attribute #66

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

Closed
hsellik opened this issue Dec 16, 2019 · 6 comments
Closed

'Tree' object has no attribute #66

hsellik opened this issue Dec 16, 2019 · 6 comments

Comments

@hsellik
Copy link

hsellik commented Dec 16, 2019

Describe the bug:
Trying to analyze a git repository which was ported from SVN.

To Reproduce:
Running very simple code on repo (which should not produce any errors?):

for commit in RepositoryMining("repo/path").traverse_commits():
    for modification in commit.modifications:
        print(" with a change type of {}".format(modification.complexity))

OS Version:
MacOS

PyDriller Version:
1.9.2

Logs:

Traceback (most recent call last):
  File ".../Library/Application Support/IntelliJIdea2019.2/python/helpers/pydev/pydevd.py", line 1415, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "...//Library/Application Support/IntelliJIdea2019.2/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File ".../repo_analyzer.py", line 13, in <module>
    for m in commit.modifications:
  File “.../lib/python3.7/site-packages/pydriller/domain/commit.py", line 377, in modifications
    self._modifications = self._get_modifications()
  File “.../lib/python3.7/site-packages/pydriller/domain/commit.py", line 388, in _get_modifications
    create_patch=True)
  File “.../lib/python3.7/site-packages/git/diff.py", line 152, in diff
    index = diff_method(self.repo, proc)
  File “.../lib/python3.7/site-packages/git/diff.py", line 470, in _index_from_patch_format
    None, None, None))
  File “.../lib/python3.7/site-packages/git/diff.py", line 284, in __init__
    for submodule in repo.submodules:
  File “.../lib/python3.7/site-packages/git/repo/base.py", line 340, in submodules
    return Submodule.list_items(self)
  File “.../lib/python3.7/site-packages/git/util.py", line 928, in list_items
    out_list.extend(cls.iter_items(repo, *args, **kwargs))
  File “.../lib/python3.7/site-packages/git/objects/submodule/base.py", line 1192, in iter_items
    sm._name = n
AttributeError: 'Tree' object has no attribute '_name'

Any idea what could be the issue here?

@ishepard
Copy link
Owner

Hi @hsellik!
From the stack trace, I see the error happens in GitPython (git/objects/submodule/base.py).
Would it be possible for you to share the repository you're using? So I can test it personally. GitHub URL or similar will work.

Thank you!

@hsellik
Copy link
Author

hsellik commented Dec 16, 2019

Hi @ishepard

Unfortunately, it's not possible for me to share the repository.

@mauricioaniche
Copy link
Collaborator

Based on readthedocs/readthedocs.org#4371 and gitpython-developers/GitPython#279, I'd try to give pydriller a git repository with a submodule, and see if this exception can be reproduced in a more isolated way.

@hsellik
Copy link
Author

hsellik commented Dec 17, 2019

Okay, so I tried with a small example project and it works perfectly fine.

However, I noticed that the repository I wish to work with has the submodules in the .gitmodules file, but the module folders themselves are not pushed to the repository (they should be according to Git documentation, also described in this Stackoverflow post).

Removing the .gitmodules file makes PyDriller code work again. I think it's safe to assume that this is an error on the project side, at least in my case.

@hsellik hsellik closed this as completed Dec 17, 2019
@ishepard
Copy link
Owner

Perfect, good to know this! Thanks for taking the time investigating the error 😄
Happy mining!

@mohmehmo
Copy link

mohmehmo commented Aug 27, 2021

Hi,
Here is the link of an example repository with the same problem.

https://github.com/OleguerCanal/kaggle_digit-recognizer

Actually, When I wanted to mine the commit with cfa77e0 SHA, I faced with the error said

sm._name = n
AttributeError: 'Tree' object has no attribute '_name'

Can you please check it and let me know how can I address this problem?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants