fix: handle directory creation errors in setup_git_home

This commit is contained in:
Paul Gauthier (aider) 2024-08-28 11:21:28 -07:00
parent 2192a5efb2
commit a57d9e55d6
2 changed files with 42 additions and 8 deletions

View file

@ -58,15 +58,23 @@ def setup_git_home(io):
# Assume it's a new project name
project_name = choice
new_dir = home / project_name
new_dir.mkdir(parents=True, exist_ok=True)
os.chdir(new_dir)
return str(new_dir)
try:
new_dir.mkdir(parents=True, exist_ok=True)
os.chdir(new_dir)
return str(new_dir)
except OSError as e:
io.tool_error(f"Error creating directory: {e}")
return None
project_name = io.user_input("Enter a name for your new project directory:")
new_dir = home / project_name
new_dir.mkdir(parents=True, exist_ok=True)
os.chdir(new_dir)
return str(new_dir)
try:
new_dir.mkdir(parents=True, exist_ok=True)
os.chdir(new_dir)
return str(new_dir)
except OSError as e:
io.tool_error(f"Error creating directory: {e}")
return None
def get_git_root():