mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 13:54:59 +00:00
Handle existing dirnames with [globby] chars, with test #195
This commit is contained in:
parent
a3a4d87a0c
commit
e610e5bd0a
2 changed files with 23 additions and 4 deletions
|
@ -349,10 +349,12 @@ class Commands:
|
||||||
self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.")
|
self.io.tool_error(f"Skipping {fname} that matches aiderignore spec.")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if fname.exists() and fname.is_file():
|
if fname.exists():
|
||||||
|
if fname.is_file():
|
||||||
all_matched_files.add(str(fname))
|
all_matched_files.add(str(fname))
|
||||||
continue
|
continue
|
||||||
# an existing dir will fall through and get recursed by glob
|
# an existing dir, escape any special chars so they won't be globs
|
||||||
|
word = re.sub(r"([\*\?\[\]])", r"[\1]", word)
|
||||||
|
|
||||||
matched_files = self.glob_filtered_to_repo(word)
|
matched_files = self.glob_filtered_to_repo(word)
|
||||||
if matched_files:
|
if matched_files:
|
||||||
|
|
|
@ -386,6 +386,23 @@ class TestCommands(TestCase):
|
||||||
|
|
||||||
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
||||||
|
|
||||||
|
def test_cmd_add_dirname_with_special_chars(self):
|
||||||
|
with ChdirTemporaryDirectory():
|
||||||
|
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()
|
||||||
|
|
||||||
|
commands.cmd_add(str(dname))
|
||||||
|
|
||||||
|
self.assertIn(str(fname.resolve()), coder.abs_fnames)
|
||||||
|
|
||||||
def test_cmd_add_abs_filename(self):
|
def test_cmd_add_abs_filename(self):
|
||||||
with ChdirTemporaryDirectory():
|
with ChdirTemporaryDirectory():
|
||||||
io = InputOutput(pretty=False, yes=False)
|
io = InputOutput(pretty=False, yes=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue