fixed spurious "Adding to git" messages when running aider in subdir of repo

This commit is contained in:
Paul Gauthier 2023-08-17 08:32:44 -07:00
parent 6359376953
commit 6e9fbdcb6a
2 changed files with 30 additions and 3 deletions

View file

@ -170,3 +170,27 @@ class TestRepo(unittest.TestCase):
fnames = git_repo.get_tracked_files()
self.assertIn(str(fname), fnames)
self.assertIn(str(fname2), fnames)
def test_get_tracked_files_from_subdir(self):
with GitTemporaryDirectory():
# new repo
raw_repo = git.Repo()
# add it, but no commits at all in the raw_repo yet
fname = Path("subdir/new.txt")
fname.parent.mkdir()
fname.touch()
raw_repo.git.add(str(fname))
os.chdir(fname.parent)
git_repo = GitRepo(InputOutput(), None, None)
# 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)