gitinspector icon indicating copy to clipboard operation
gitinspector copied to clipboard

Authorless commits crash tool

Open cujomalainey opened this issue 2 years ago • 5 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

cujomalainey avatar Feb 28 '22 22:02 cujomalainey

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

uberkael avatar Apr 19 '22 21:04 uberkael

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.

adam-waldenberg avatar May 04 '22 04:05 adam-waldenberg

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.

dirtcrusher avatar Sep 29 '22 14:09 dirtcrusher

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.

adam-waldenberg avatar Jan 11 '23 21:01 adam-waldenberg