mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 10:14:59 +00:00
refactor: Move Path.cwd() call to top of setup_git and add OSError handling
This commit is contained in:
parent
21b88c0e65
commit
5751bcd382
1 changed files with 7 additions and 2 deletions
|
@ -87,15 +87,20 @@ def make_new_repo(git_root, io):
|
||||||
|
|
||||||
|
|
||||||
def setup_git(git_root, io):
|
def setup_git(git_root, io):
|
||||||
|
try:
|
||||||
|
cwd = Path.cwd()
|
||||||
|
except OSError:
|
||||||
|
return None
|
||||||
|
|
||||||
repo = None
|
repo = None
|
||||||
|
|
||||||
if git_root:
|
if git_root:
|
||||||
repo = git.Repo(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.")
|
io.tool_warning("You should probably run aider in a directory, not your home dir.")
|
||||||
return
|
return
|
||||||
elif io.confirm_ask("No git repo found, create one to track aider's changes (recommended)?"):
|
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)
|
repo = make_new_repo(git_root, io)
|
||||||
|
|
||||||
if not repo:
|
if not repo:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue