mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
test: Add test to verify cmd_add respects .gitignore files
This commit is contained in:
parent
bc82baa968
commit
1450c4194e
1 changed files with 24 additions and 0 deletions
|
@ -1210,6 +1210,30 @@ class TestCommands(TestCase):
|
||||||
del commands
|
del commands
|
||||||
del repo
|
del repo
|
||||||
|
|
||||||
|
def test_cmd_add_gitignored_file(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
repo = git.Repo()
|
||||||
|
|
||||||
|
# Create and commit a .gitignore file
|
||||||
|
gitignore = Path(".gitignore")
|
||||||
|
gitignore.write_text("*.ignored\n")
|
||||||
|
repo.git.add(".gitignore")
|
||||||
|
repo.git.commit("-m", "Add .gitignore")
|
||||||
|
|
||||||
|
# Create a file that matches the gitignore pattern
|
||||||
|
ignored_file = Path("test.ignored")
|
||||||
|
ignored_file.write_text("This should be ignored")
|
||||||
|
|
||||||
|
io = InputOutput(pretty=False, fancy_input=False, yes=False)
|
||||||
|
coder = Coder.create(self.GPT35, None, io)
|
||||||
|
commands = Commands(io, coder)
|
||||||
|
|
||||||
|
# Try to add the ignored file
|
||||||
|
commands.cmd_add(str(ignored_file))
|
||||||
|
|
||||||
|
# Verify the file was not added
|
||||||
|
self.assertEqual(len(coder.abs_fnames), 0)
|
||||||
|
|
||||||
def test_cmd_add_aiderignored_file(self):
|
def test_cmd_add_aiderignored_file(self):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
repo = git.Repo()
|
repo = git.Repo()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue