mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-27 15:55:00 +00:00
refactor: Improve error handling in git repository checks
This commit is contained in:
parent
3cd6790d9a
commit
4e63254704
2 changed files with 15 additions and 12 deletions
|
@ -302,15 +302,15 @@ def sanity_check_repo(repo, io):
|
|||
|
||||
try:
|
||||
repo.get_tracked_files()
|
||||
if not repo.git_repo_error:
|
||||
return True
|
||||
error_msg = str(repo.git_repo_error)
|
||||
except ANY_GIT_ERROR as exc:
|
||||
error_msg = str(exc)
|
||||
|
||||
if "version in (1, 2)" in error_msg:
|
||||
io.tool_error("Aider only works with git repos with version number 1 or 2.")
|
||||
io.tool_output(
|
||||
"You may be able to convert your repo: git update-index --index-version=2"
|
||||
)
|
||||
io.tool_output("You may be able to convert your repo: git update-index --index-version=2")
|
||||
io.tool_output("Or run aider --no-git to proceed without using git.")
|
||||
io.tool_output("https://github.com/paul-gauthier/aider/issues/211")
|
||||
return False
|
||||
|
|
|
@ -21,6 +21,7 @@ class GitRepo:
|
|||
aider_ignore_last_check = 0
|
||||
subtree_only = False
|
||||
ignore_file_cache = {}
|
||||
git_repo_error = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -258,6 +259,7 @@ class GitRepo:
|
|||
except ValueError:
|
||||
commit = None
|
||||
except ANY_GIT_ERROR as err:
|
||||
self.git_repo_error = err
|
||||
self.io.tool_error(f"Unable to list files in git repo: {err}")
|
||||
self.io.tool_output("Is your git repo corrupted?")
|
||||
return []
|
||||
|
@ -272,6 +274,7 @@ class GitRepo:
|
|||
if blob.type == "blob": # blob is a file
|
||||
files.add(blob.path)
|
||||
except ANY_GIT_ERROR as err:
|
||||
self.git_repo_error = err
|
||||
self.io.tool_error(f"Unable to list files in git repo: {err}")
|
||||
self.io.tool_output("Is your git repo corrupted?")
|
||||
return []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue