fix: handle case of brand new repository with no commits

This commit is contained in:
Paul Gauthier (aider) 2024-08-09 19:35:15 -04:00
parent 423b6e1ad1
commit d9e7d64235

View file

@ -670,7 +670,11 @@ class Coder:
self.test_outcome = None
self.edit_outcome = None
if self.repo:
self.commit_before_message = self.repo.repo.head.commit.hexsha
try:
self.commit_before_message = self.repo.repo.head.commit.hexsha
except ValueError:
# This occurs when the repository is brand new and has no commits
self.commit_before_message = None
else:
self.commit_before_message = None