From 5751bcd382b7857f84ee1227e5001da2270e403c Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 11 Nov 2024 09:54:43 -0800 Subject: [PATCH] refactor: Move Path.cwd() call to top of setup_git and add OSError handling --- aider/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aider/main.py b/aider/main.py index 179d4560f..cd25b2445 100644 --- a/aider/main.py +++ b/aider/main.py @@ -87,15 +87,20 @@ def make_new_repo(git_root, io): def setup_git(git_root, io): + try: + cwd = Path.cwd() + except OSError: + return None + repo = None if git_root: repo = git.Repo(git_root) - elif Path.cwd() == Path.home(): + elif cwd == Path.home(): io.tool_warning("You should probably run aider in a directory, not your home dir.") return elif io.confirm_ask("No git repo found, create one to track aider's changes (recommended)?"): - git_root = str(Path.cwd().resolve()) + git_root = str(cwd.resolve()) repo = make_new_repo(git_root, io) if not repo: