mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 14:55:00 +00:00
test case and fix for /add blowing up in subdir #201
This commit is contained in:
parent
545f10551e
commit
98bacd0b5b
2 changed files with 26 additions and 6 deletions
|
@ -279,16 +279,17 @@ class Commands:
|
||||||
if any(char in word for char in "*?[]"):
|
if any(char in word for char in "*?[]"):
|
||||||
self.io.tool_error(f"No files to add matching pattern: {word}")
|
self.io.tool_error(f"No files to add matching pattern: {word}")
|
||||||
else:
|
else:
|
||||||
if Path(word).exists():
|
fname = Path(self.coder.root) / word
|
||||||
if Path(word).is_file():
|
if fname.exists():
|
||||||
matched_files = [word]
|
if fname.is_file():
|
||||||
|
matched_files = [str(fname)]
|
||||||
else:
|
else:
|
||||||
self.io.tool_error(f"Unable to add: {word}")
|
self.io.tool_error(f"Unable to add: {word}")
|
||||||
elif self.io.confirm_ask(
|
elif self.io.confirm_ask(
|
||||||
f"No files matched '{word}'. Do you want to create the file?"
|
f"No files matched '{word}'. Do you want to create {fname}?"
|
||||||
):
|
):
|
||||||
(Path(self.coder.root) / word).touch()
|
fname.touch()
|
||||||
matched_files = [word]
|
matched_files = [str(fname)]
|
||||||
|
|
||||||
all_matched_files.update(matched_files)
|
all_matched_files.update(matched_files)
|
||||||
|
|
||||||
|
|
|
@ -276,3 +276,22 @@ class TestCommands(TestCase):
|
||||||
commit_message = "Test commit message"
|
commit_message = "Test commit message"
|
||||||
commands.cmd_commit(commit_message)
|
commands.cmd_commit(commit_message)
|
||||||
self.assertFalse(repo.is_dirty())
|
self.assertFalse(repo.is_dirty())
|
||||||
|
|
||||||
|
def test_cmd_add_from_sub_dir(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
io = InputOutput(pretty=False, yes=False)
|
||||||
|
from aider.coders import Coder
|
||||||
|
|
||||||
|
coder = Coder.create(models.GPT35, None, io)
|
||||||
|
commands = Commands(io, coder)
|
||||||
|
|
||||||
|
Path("side_dir").mkdir()
|
||||||
|
os.chdir("side_dir")
|
||||||
|
|
||||||
|
# add a file that is in the side_dir
|
||||||
|
with open("temp.txt", "w"):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# this was blowing up with GitCommandError, per:
|
||||||
|
# https://github.com/paul-gauthier/aider/issues/201
|
||||||
|
commands.cmd_add("temp.txt")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue