mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
wip
This commit is contained in:
parent
b2846fa73a
commit
7fc02ccd66
1 changed files with 30 additions and 27 deletions
|
@ -156,40 +156,43 @@ class Commands:
|
||||||
def cmd_add(self, args):
|
def cmd_add(self, args):
|
||||||
"Add matching files to the chat session"
|
"Add matching files to the chat session"
|
||||||
|
|
||||||
|
from aider.dump import dump
|
||||||
|
|
||||||
added_fnames = []
|
added_fnames = []
|
||||||
files = self.coder.get_all_relative_files()
|
files = self.coder.get_all_relative_files()
|
||||||
for word in args.split():
|
for word in args.split():
|
||||||
matched_files = [file for file in files if word in file]
|
matched_files = [file for file in files if word in file]
|
||||||
|
|
||||||
if not matched_files:
|
dump(word, matched_files)
|
||||||
if self.coder.repo is not None:
|
if not matched_files:
|
||||||
create_file = Confirm.ask(
|
|
||||||
f"No files matched '{word}'. Do you want to create the file and add it to git?",
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
create_file = Confirm.ask(
|
|
||||||
f"No files matched '{word}'. Do you want to create the file?"
|
|
||||||
)
|
|
||||||
|
|
||||||
if create_file:
|
|
||||||
with open(os.path.join(self.coder.root, word), "w"):
|
|
||||||
pass
|
|
||||||
matched_files = [word]
|
|
||||||
if self.coder.repo is not None:
|
if self.coder.repo is not None:
|
||||||
self.coder.repo.git.add(os.path.join(self.coder.root, word))
|
create_file = Confirm.ask(
|
||||||
commit_message = f"aider: Created and added {word} to git."
|
f"No files matched '{word}'. Do you want to create the file and add it to git?",
|
||||||
self.coder.repo.git.commit("-m", commit_message, "--no-verify")
|
)
|
||||||
else:
|
else:
|
||||||
self.io.tool_error(f"No files matched '{word}'")
|
create_file = Confirm.ask(
|
||||||
|
f"No files matched '{word}'. Do you want to create the file?"
|
||||||
|
)
|
||||||
|
|
||||||
for matched_file in matched_files:
|
if create_file:
|
||||||
abs_file_path = os.path.abspath(os.path.join(self.coder.root, matched_file))
|
with open(os.path.join(self.coder.root, word), "w"):
|
||||||
if abs_file_path not in self.coder.abs_fnames:
|
pass
|
||||||
self.coder.abs_fnames.add(abs_file_path)
|
matched_files = [word]
|
||||||
self.io.tool(f"Added {matched_file} to the chat")
|
if self.coder.repo is not None:
|
||||||
added_fnames.append(matched_file)
|
self.coder.repo.git.add(os.path.join(self.coder.root, word))
|
||||||
else:
|
commit_message = f"aider: Created and added {word} to git."
|
||||||
self.io.tool_error(f"{matched_file} is already in the chat")
|
self.coder.repo.git.commit("-m", commit_message, "--no-verify")
|
||||||
|
else:
|
||||||
|
self.io.tool_error(f"No files matched '{word}'")
|
||||||
|
|
||||||
|
for matched_file in matched_files:
|
||||||
|
abs_file_path = os.path.abspath(os.path.join(self.coder.root, matched_file))
|
||||||
|
if abs_file_path not in self.coder.abs_fnames:
|
||||||
|
self.coder.abs_fnames.add(abs_file_path)
|
||||||
|
self.io.tool(f"Added {matched_file} to the chat")
|
||||||
|
added_fnames.append(matched_file)
|
||||||
|
else:
|
||||||
|
self.io.tool_error(f"{matched_file} is already in the chat")
|
||||||
|
|
||||||
if not added_fnames:
|
if not added_fnames:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue