mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-23 05:45:00 +00:00
Added a test case to fail if git posix paths are not turned into windows paths
This commit is contained in:
parent
b3d624b7cd
commit
c6696e7245
2 changed files with 20 additions and 9 deletions
|
@ -6,7 +6,7 @@ import os
|
|||
import sys
|
||||
import traceback
|
||||
from json.decoder import JSONDecodeError
|
||||
from pathlib import Path
|
||||
from pathlib import Path, PurePosixPath
|
||||
|
||||
import backoff
|
||||
import git
|
||||
|
@ -248,17 +248,10 @@ class Coder:
|
|||
self.repo = git.Repo(repo_paths.pop(), odbt=git.GitDB)
|
||||
|
||||
self.root = os.path.abspath(self.repo.working_tree_dir)
|
||||
if self.verbose:
|
||||
dump(self.repo)
|
||||
dump(self.root)
|
||||
dump(os.getcwd())
|
||||
|
||||
new_files = []
|
||||
for fname in self.abs_fnames:
|
||||
relative_fname = self.get_rel_fname(fname)
|
||||
if self.verbose:
|
||||
dump(fname)
|
||||
dump(relative_fname)
|
||||
|
||||
tracked_files = set(self.get_tracked_files())
|
||||
if relative_fname not in tracked_files:
|
||||
|
@ -962,6 +955,7 @@ 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)
|
||||
|
|
|
@ -2,6 +2,7 @@ import os
|
|||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
|
@ -37,9 +38,25 @@ class TestMain(TestCase):
|
|||
subprocess.run(["git", "init"])
|
||||
subprocess.run(["git", "config", "user.email", "dummy@example.com"])
|
||||
subprocess.run(["git", "config", "user.name", "Dummy User"])
|
||||
main(["--verbose", "--yes", "foo.txt"], input=DummyInput(), output=DummyOutput())
|
||||
main(["--yes", "foo.txt"], input=DummyInput(), output=DummyOutput())
|
||||
self.assertTrue(os.path.exists("foo.txt"))
|
||||
|
||||
def test_main_with_empty_git_dir_new_subdir_file(self):
|
||||
subprocess.run(["git", "init"])
|
||||
subprocess.run(["git", "config", "user.email", "dummy@example.com"])
|
||||
subprocess.run(["git", "config", "user.name", "Dummy User"])
|
||||
subdir = Path("subdir")
|
||||
subdir.mkdir()
|
||||
fname = subdir / "foo.txt"
|
||||
fname.touch()
|
||||
subprocess.run(["git", "add", str(subdir)])
|
||||
subprocess.run(["git", "commit", "-m", "added"])
|
||||
|
||||
# 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())
|
||||
|
||||
def test_main_args(self):
|
||||
with patch("aider.main.Coder.create") as MockCoder:
|
||||
main(["--no-auto-commits"], input=DummyInput())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue