fix: Add support for directories with special characters in cmd_add

This commit is contained in:
Paul Gauthier 2024-08-25 12:05:31 -07:00 committed by Paul Gauthier (aider)
parent 7b2379c7c2
commit 65d224fba4
2 changed files with 24 additions and 0 deletions

View file

@ -31,6 +31,7 @@ ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
4. *Concisely* suggest any shell commands the user might want to run in ```bash blocks. 4. *Concisely* suggest any shell commands the user might want to run in ```bash blocks.
Just suggest shell commands this way, not example code. Just suggest shell commands this way, not example code.
Only suggest complete shell commands that area ready to execute, without placeholders.
Use the appropriate shell based on the user's system info: Use the appropriate shell based on the user's system info:
{platform} {platform}

View file

@ -452,6 +452,29 @@ class TestCommands(TestCase):
commands.cmd_add(str(dname)) commands.cmd_add(str(dname))
dump(coder.abs_fnames)
self.assertIn(str(fname.resolve()), coder.abs_fnames)
def test_cmd_add_dirname_with_special_chars_git(self):
with GitTemporaryDirectory():
io = InputOutput(pretty=False, yes=False)
from aider.coders import Coder
coder = Coder.create(self.GPT35, None, io)
commands = Commands(io, coder)
dname = Path("with[brackets]")
dname.mkdir()
fname = dname / "filename.txt"
fname.touch()
repo = git.Repo()
repo.git.add(str(fname))
repo.git.commit("-m", "init")
commands.cmd_add(str(dname))
dump(coder.abs_fnames)
self.assertIn(str(fname.resolve()), coder.abs_fnames) self.assertIn(str(fname.resolve()), coder.abs_fnames)
def test_cmd_add_abs_filename(self): def test_cmd_add_abs_filename(self):