fix: Catch ValueError when getting current commit in cmd_diff

This commit is contained in:
Paul Gauthier (aider) 2024-08-09 19:38:12 -04:00
parent 543227f6bd
commit 55d55c32b2

View file

@ -471,7 +471,12 @@ class Commands:
self.io.tool_error("No git repository found.")
return
current_head = self.coder.repo.repo.head.commit.hexsha
try:
current_head = self.coder.repo.repo.head.commit.hexsha
except ValueError:
self.io.tool_error("Unable to get current commit. The repository might be empty.")
return
commit_before_message = self.coder.commit_before_message
if not commit_before_message or commit_before_message == current_head: