From e996c56a51268440dc47f5e29c5f0234c502d54f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 5 Jul 2023 16:55:37 -0700 Subject: [PATCH] more robust get_tracked_files with pathlib --- aider/coders/base_coder.py | 6 ++---- tests/test_main.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 3c756f0da..a24d7136c 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -955,10 +955,8 @@ class Coder: def get_tracked_files(self): # convert to appropriate os.sep, since git always normalizes to / files = set(self.repo.git.ls_files().splitlines()) - # return files - if os.sep == "/": - return files - return set(path.replace("/", os.sep) for path in files) + res = set(str(Path(PurePosixPath(path))) for path in files) + return res apply_update_errors = 0 diff --git a/tests/test_main.py b/tests/test_main.py index 248e61bca..5fd752ca7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -55,7 +55,7 @@ class TestMain(TestCase): # This will throw a git error on windows if get_tracked_files doesn't # properly convert git/posix/paths to git\posix\paths. # Because aider will try and `git add` a file that's already in the repo. - main(["--yes", "--verbose", str(fname)], input=DummyInput(), output=DummyOutput()) + main(["--yes", str(fname)], input=DummyInput(), output=DummyOutput()) def test_main_args(self): with patch("aider.main.Coder.create") as MockCoder: