mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-20 04:14:59 +00:00
fix: base coder not ignoring gitignore if --file is used.
This commit is contained in:
parent
0049e78250
commit
bc1272f029
2 changed files with 31 additions and 0 deletions
|
@ -445,6 +445,7 @@ class Coder:
|
||||||
fname = Path(fname)
|
fname = Path(fname)
|
||||||
if self.repo and self.repo.git_ignored_file(fname):
|
if self.repo and self.repo.git_ignored_file(fname):
|
||||||
self.io.tool_warning(f"Skipping {fname} that matches gitignore spec.")
|
self.io.tool_warning(f"Skipping {fname} that matches gitignore spec.")
|
||||||
|
continue
|
||||||
|
|
||||||
if self.repo and self.repo.ignored_file(fname):
|
if self.repo and self.repo.ignored_file(fname):
|
||||||
self.io.tool_warning(f"Skipping {fname} that matches aiderignore spec.")
|
self.io.tool_warning(f"Skipping {fname} that matches aiderignore spec.")
|
||||||
|
|
|
@ -1278,6 +1278,21 @@ class TestMain(TestCase):
|
||||||
for call in mock_io_instance.tool_warning.call_args_list:
|
for call in mock_io_instance.tool_warning.call_args_list:
|
||||||
self.assertNotIn("Cost estimates may be inaccurate", call[0][0])
|
self.assertNotIn("Cost estimates may be inaccurate", call[0][0])
|
||||||
|
|
||||||
|
def test_argv_file_respects_git(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
fname = Path("not_in_git.txt")
|
||||||
|
fname.touch()
|
||||||
|
with open(".gitignore", "w+") as f:
|
||||||
|
f.write("not_in_git.txt")
|
||||||
|
coder = main(
|
||||||
|
argv=["--file", "not_in_git.txt"],
|
||||||
|
input=DummyInput(),
|
||||||
|
output=DummyOutput(),
|
||||||
|
return_coder=True,
|
||||||
|
)
|
||||||
|
self.assertNotIn("not_in_git.txt", str(coder.abs_fnames))
|
||||||
|
self.assertFalse(coder.allowed_to_edit("not_in_git.txt"))
|
||||||
|
|
||||||
def test_load_dotenv_files_override(self):
|
def test_load_dotenv_files_override(self):
|
||||||
with GitTemporaryDirectory() as git_dir:
|
with GitTemporaryDirectory() as git_dir:
|
||||||
git_dir = Path(git_dir)
|
git_dir = Path(git_dir)
|
||||||
|
@ -1348,3 +1363,18 @@ class TestMain(TestCase):
|
||||||
)
|
)
|
||||||
for call in mock_io_instance.tool_warning.call_args_list:
|
for call in mock_io_instance.tool_warning.call_args_list:
|
||||||
self.assertNotIn("Cost estimates may be inaccurate", call[0][0])
|
self.assertNotIn("Cost estimates may be inaccurate", call[0][0])
|
||||||
|
|
||||||
|
def test_argv_file_respects_git(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
fname = Path("not_in_git.txt")
|
||||||
|
fname.touch()
|
||||||
|
with open(".gitignore", "w+") as f:
|
||||||
|
f.write("not_in_git.txt")
|
||||||
|
coder = main(
|
||||||
|
argv=["--file", "not_in_git.txt"],
|
||||||
|
input=DummyInput(),
|
||||||
|
output=DummyOutput(),
|
||||||
|
return_coder=True,
|
||||||
|
)
|
||||||
|
self.assertNotIn("not_in_git.txt", str(coder.abs_fnames))
|
||||||
|
self.assertFalse(coder.allowed_to_edit("not_in_git.txt"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue