refactor: improve error handling for git version check

This commit is contained in:
Paul Gauthier 2024-09-09 13:44:02 -07:00 committed by Paul Gauthier (aider)
parent 00f42590c8
commit bd21122e64
2 changed files with 6 additions and 2 deletions

View file

@ -307,8 +307,12 @@ def sanity_check_repo(repo, io):
error_msg = str(repo.git_repo_error) error_msg = str(repo.git_repo_error)
except ANY_GIT_ERROR as exc: except ANY_GIT_ERROR as exc:
error_msg = str(exc) error_msg = str(exc)
bad_ver = "version in (1, 2)" in error_msg
except AssertionError as exc:
error_msg = str(exc)
bad_ver = True
if "version in (1, 2)" in error_msg: if bad_ver:
io.tool_error("Aider only works with git repos with version number 1 or 2.") 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("Or run aider --no-git to proceed without using git.")

View file

@ -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, OSError, AssertionError) ANY_GIT_ERROR = (git.exc.ODBError, git.exc.GitError, OSError)
class GitRepo: class GitRepo: