fix: Set git_root to None if no git repositories are found in the home directory

This commit is contained in:
Paul Gauthier 2024-08-28 15:28:05 -07:00 committed by Paul Gauthier (aider)
parent b8a52c2bef
commit 6f09f651a1

View file

@ -25,6 +25,7 @@ from .dump import dump # noqa: F401
def setup_git_home(io): def setup_git_home(io):
home = Path.home() home = Path.home()
git_repos = list(home.glob("*/.git")) git_repos = list(home.glob("*/.git"))
git_root = None
if git_repos: if git_repos:
io.tool_output("Found git repositories in your home directory:") io.tool_output("Found git repositories in your home directory:")
@ -61,6 +62,9 @@ def setup_git_home(io):
else: else:
return # no response return # no response
if not git_root:
return
if git_root.exists(): if git_root.exists():
if git_root.is_dir(): if git_root.is_dir():
os.chdir(git_root) os.chdir(git_root)