Skip to content
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

Authorless commits crash tool #230

Open
cujomalainey opened this issue Feb 28, 2022 · 5 comments
Open

Authorless commits crash tool #230

cujomalainey opened this issue Feb 28, 2022 · 5 comments

Comments

@cujomalainey
Copy link

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

@uberkael
Copy link

uberkael commented Apr 19, 2022

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

@adam-waldenberg
Copy link
Member

adam-waldenberg commented May 4, 2022

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.

@dirtcrusher
Copy link

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.

@adam-waldenberg
Copy link
Member

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.

@FeXd
Copy link

FeXd commented Jun 7, 2024

I just ran into the exact same issue with a class I am teaching.

The error I'm getting:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "C:\Users\xxx\gitinspector\changes.py", line 151, in run
    bisect.insort(commits, commit)
  File "C:\Users\xxx\gitinspector\changes.py", line 82, in __lt__
    return self.timestamp.__lt__(other.timestamp) # only used for sorting; we just consider the timestamp.
AttributeError: 'Commit' object has no attribute 'timestamp'

Following @dirtcrusher's suggestions and deleting or i is lines[-1] from here allows everything to run.

I've tried some other Python 3.x versions and am getting the same result.

The line of code in question was introduce in the second commit of the project here.

FeXd added a commit to Interactive-Design-and-Technology/gitinspector that referenced this issue Jun 7, 2024
- was getting `AttributeError: 'Commit' object has no attribute 'timestamp'`
- found conversation about similar issue here: ejwa#230
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

5 participants