mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
fix: handle OSError in git repo operations
This commit is contained in:
parent
d82d21b8c1
commit
3cd6790d9a
1 changed files with 10 additions and 5 deletions
|
@ -10,7 +10,7 @@ from aider.sendchat import simple_send_with_retries
|
||||||
|
|
||||||
from .dump import dump # noqa: F401
|
from .dump import dump # noqa: F401
|
||||||
|
|
||||||
ANY_GIT_ERROR = (git.exc.ODBError, git.exc.GitError)
|
ANY_GIT_ERROR = (git.exc.ODBError, git.exc.GitError, OSError)
|
||||||
|
|
||||||
|
|
||||||
class GitRepo:
|
class GitRepo:
|
||||||
|
@ -257,7 +257,7 @@ class GitRepo:
|
||||||
commit = self.repo.head.commit
|
commit = self.repo.head.commit
|
||||||
except ValueError:
|
except ValueError:
|
||||||
commit = None
|
commit = None
|
||||||
except (OSError,) + ANY_GIT_ERROR as err:
|
except ANY_GIT_ERROR as err:
|
||||||
self.io.tool_error(f"Unable to list files in git repo: {err}")
|
self.io.tool_error(f"Unable to list files in git repo: {err}")
|
||||||
self.io.tool_output("Is your git repo corrupted?")
|
self.io.tool_output("Is your git repo corrupted?")
|
||||||
return []
|
return []
|
||||||
|
@ -267,9 +267,14 @@ class GitRepo:
|
||||||
if commit in self.tree_files:
|
if commit in self.tree_files:
|
||||||
files = self.tree_files[commit]
|
files = self.tree_files[commit]
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
for blob in commit.tree.traverse():
|
for blob in commit.tree.traverse():
|
||||||
if blob.type == "blob": # blob is a file
|
if blob.type == "blob": # blob is a file
|
||||||
files.add(blob.path)
|
files.add(blob.path)
|
||||||
|
except ANY_GIT_ERROR as err:
|
||||||
|
self.io.tool_error(f"Unable to list files in git repo: {err}")
|
||||||
|
self.io.tool_output("Is your git repo corrupted?")
|
||||||
|
return []
|
||||||
files = set(self.normalize_path(path) for path in files)
|
files = set(self.normalize_path(path) for path in files)
|
||||||
self.tree_files[commit] = set(files)
|
self.tree_files[commit] = set(files)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue