ejwa / gitinspector

:bar_chart: The statistical analysis tool for git repositories

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Authorless commits crash tool

cujomalainey opened this issue · comments

Traceback (most recent call last):
  File "/usr/bin/gitinspector", line 33, in <module>
    sys.exit(load_entry_point('gitinspector==0.4.4', 'console_scripts', 'gitinspector')())
  File "/usr/lib/python3/dist-packages/gitinspector/gitinspector.py", line 184, in main
    __run__.output()
  File "/usr/lib/python3/dist-packages/gitinspector/gitinspector.py", line 75, in output
    outputable.output(changes.ChangesOutput(self.hard))
  File "/usr/lib/python3/dist-packages/gitinspector/outputable.py", line 38, in output
    outputable.output_text()
  File "/usr/lib/python3/dist-packages/gitinspector/changes.py", line 343, in output_text
    authorinfo_list = self.changes.get_authorinfo_list()
  File "/usr/lib/python3/dist-packages/gitinspector/changes.py", line 242, in get_authorinfo_list
    Changes.modify_authorinfo(self.authors, i.author, i)
AttributeError: 'Commit' object has no attribute 'author'

Tool was run on https://github.com/zephyrproject-rtos/zephyr

I "solved" it for plain text (for HTML continues to crash) like this:

--- <gitinspector/changes.py>
+++ <gitinspector/changes.py>
 	def get_authorinfo_list(self):
 		if not self.authors:
 			for i in self.commits:
-				Changes.modify_authorinfo(self.authors, i.author, i)
+				Changes.modify_authorinfo(self.authors, i.author if hasattr(i, 'author') else "x", i)
 
 		return self.authors

Good catch - By authorless I'm assuming we are talking about an empty author string ? That's actually not permited by git. If you run git fsck on such a repo you should get errors. Question is what the correct behavior is here. We could certainly insert a "No Author" user into the result, but it's probably also a good idea to inform users about it and not condone invalid use of git.

I'm having this issue as well on a private (work) repository, and I do not have any authorless commits in the repository.

I'm not familiar with the codebase, but I attempted some debugging.

I found some invalid strings passed to the Commit constructor (1 file changed, 1 insertion(+), 1 deletion(-)).

When I removed the or i is lines[-1] from here, the error went away.

I added a print statement of i when i is lines[-1], and I had a lot of empty lines + the invalid strings I mentioned before.

This is where I'm stuck for now, but I hope that my experiments can help someone find the actual bug.

I'm having this issue as well on a private (work) repository, and I do not have any authorless commits in the repository.

I'm not familiar with the codebase, but I attempted some debugging.

I found some invalid strings passed to the Commit constructor (1 file changed, 1 insertion(+), 1 deletion(-)).

When I removed the or i is lines[-1] from here, the error went away.

I added a print statement of i when i is lines[-1], and I had a lot of empty lines + the invalid strings I mentioned before.

This is where I'm stuck for now, but I hope that my experiments can help someone find the actual bug.

If you don't have any authorless commits, then this mandates further investigation I would say.