mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
added tests, fixed bug
This commit is contained in:
parent
9725b236a3
commit
583c3285ec
2 changed files with 41 additions and 0 deletions
|
@ -202,6 +202,9 @@ class GitRepo:
|
||||||
if not self.aider_ignore_file:
|
if not self.aider_ignore_file:
|
||||||
return fnames
|
return fnames
|
||||||
|
|
||||||
|
if not Path(self.aider_ignore_file).is_file():
|
||||||
|
return fnames
|
||||||
|
|
||||||
with open(self.aider_ignore_file, "r") as f:
|
with open(self.aider_ignore_file, "r") as f:
|
||||||
ignore_spec = pathspec.PathSpec.from_lines("gitwildmatch", f)
|
ignore_spec = pathspec.PathSpec.from_lines("gitwildmatch", f)
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,44 @@ class TestRepo(unittest.TestCase):
|
||||||
self.assertIn(str(fname), fnames)
|
self.assertIn(str(fname), fnames)
|
||||||
self.assertIn(str(fname2), fnames)
|
self.assertIn(str(fname2), fnames)
|
||||||
|
|
||||||
|
def test_get_tracked_files_with_aiderignore(self):
|
||||||
|
with GitTemporaryDirectory():
|
||||||
|
# new repo
|
||||||
|
raw_repo = git.Repo()
|
||||||
|
|
||||||
|
# add it, but no commits at all in the raw_repo yet
|
||||||
|
fname = Path("new.txt")
|
||||||
|
fname.touch()
|
||||||
|
raw_repo.git.add(str(fname))
|
||||||
|
|
||||||
|
git_repo = GitRepo(InputOutput(), None, None, ".aiderignore")
|
||||||
|
|
||||||
|
# better be there
|
||||||
|
fnames = git_repo.get_tracked_files()
|
||||||
|
self.assertIn(str(fname), fnames)
|
||||||
|
|
||||||
|
# commit it, better still be there
|
||||||
|
raw_repo.git.commit("-m", "new")
|
||||||
|
fnames = git_repo.get_tracked_files()
|
||||||
|
self.assertIn(str(fname), fnames)
|
||||||
|
|
||||||
|
# new file, added but not committed
|
||||||
|
fname2 = Path("new2.txt")
|
||||||
|
fname2.touch()
|
||||||
|
raw_repo.git.add(str(fname2))
|
||||||
|
|
||||||
|
# both should be there
|
||||||
|
fnames = git_repo.get_tracked_files()
|
||||||
|
self.assertIn(str(fname), fnames)
|
||||||
|
self.assertIn(str(fname2), fnames)
|
||||||
|
|
||||||
|
Path(".aiderignore").write_text("new.txt\n")
|
||||||
|
|
||||||
|
# new.txt should be gone!
|
||||||
|
fnames = git_repo.get_tracked_files()
|
||||||
|
self.assertNotIn(str(fname), fnames)
|
||||||
|
self.assertIn(str(fname2), fnames)
|
||||||
|
|
||||||
def test_get_tracked_files_from_subdir(self):
|
def test_get_tracked_files_from_subdir(self):
|
||||||
with GitTemporaryDirectory():
|
with GitTemporaryDirectory():
|
||||||
# new repo
|
# new repo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue