mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 04:14:59 +00:00
This commit is contained in:
parent
d2acb8e95e
commit
774589b376
2 changed files with 36 additions and 7 deletions
|
@ -272,13 +272,12 @@ class Commands:
|
|||
git_files = self.coder.repo.get_tracked_files() if self.coder.repo else []
|
||||
|
||||
all_matched_files = set()
|
||||
for word in args.split():
|
||||
for word in shlex.split(args):
|
||||
fname = Path(self.coder.root) / word
|
||||
if fname.exists():
|
||||
if fname.is_file():
|
||||
all_matched_files.add(str(fname))
|
||||
continue
|
||||
# else we fall through and glob will pickup all files within a dir
|
||||
if fname.exists() and fname.is_file():
|
||||
all_matched_files.add(str(fname))
|
||||
continue
|
||||
# an existing dir will fall through and get recursed by glob
|
||||
|
||||
matched_files = self.glob_filtered_to_repo(word)
|
||||
if matched_files:
|
||||
|
@ -342,7 +341,7 @@ class Commands:
|
|||
self.io.tool_output("Dropping all files from the chat session.")
|
||||
self.coder.abs_fnames = set()
|
||||
|
||||
for word in args.split():
|
||||
for word in shlex.split(args):
|
||||
matched_files = self.glob_filtered_to_repo(word)
|
||||
|
||||
if not matched_files:
|
||||
|
|
|
@ -372,3 +372,33 @@ class TestCommands(TestCase):
|
|||
commands.cmd_add(str(fname))
|
||||
|
||||
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
||||
|
||||
def test_cmd_add_abs_filename(self):
|
||||
with ChdirTemporaryDirectory():
|
||||
io = InputOutput(pretty=False, yes=False)
|
||||
from aider.coders import Coder
|
||||
|
||||
coder = Coder.create(models.GPT35, None, io)
|
||||
commands = Commands(io, coder)
|
||||
|
||||
fname = Path("file.txt")
|
||||
fname.touch()
|
||||
|
||||
commands.cmd_add(str(fname.resolve()))
|
||||
|
||||
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
||||
|
||||
def test_cmd_add_quoted_filename(self):
|
||||
with ChdirTemporaryDirectory():
|
||||
io = InputOutput(pretty=False, yes=False)
|
||||
from aider.coders import Coder
|
||||
|
||||
coder = Coder.create(models.GPT35, None, io)
|
||||
commands = Commands(io, coder)
|
||||
|
||||
fname = Path("file with spaces.txt")
|
||||
fname.touch()
|
||||
|
||||
commands.cmd_add(f'"{fname}"')
|
||||
|
||||
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue