fix: handle GitCommandNotFound exception in make_new_repo function

This commit is contained in:
Paul Gauthier 2024-08-31 07:49:23 -07:00 committed by Paul Gauthier (aider)
parent 653f0c77ef
commit 1a5a618608
2 changed files with 2 additions and 2 deletions

View file

@ -57,7 +57,7 @@ def make_new_repo(git_root, io):
try: try:
repo = git.Repo.init(git_root) repo = git.Repo.init(git_root)
check_gitignore(git_root, io, False) check_gitignore(git_root, io, False)
except gitdb.exc.ODBError as err: # issue #1233 except (gitdb.exc.ODBError, git.exc.GitCommandNotFound) as err: # issue #1233
io.tool_error(f"Unable to create git repo in {git_root}") io.tool_error(f"Unable to create git repo in {git_root}")
io.tool_error(str(err)) io.tool_error(str(err))
return return

View file

@ -625,7 +625,7 @@ class TestMain(TestCase):
mock_git_init.side_effect = git.exc.GitCommandNotFound("git", "Command 'git' not found") mock_git_init.side_effect = git.exc.GitCommandNotFound("git", "Command 'git' not found")
try: try:
result = main(["--exit"], input=DummyInput(), output=DummyOutput()) result = main(["--exit", "--yes"], input=DummyInput(), output=DummyOutput())
except Exception as e: except Exception as e:
self.fail(f"main() raised an unexpected exception: {e}") self.fail(f"main() raised an unexpected exception: {e}")