mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-09 06:05:00 +00:00
add missing encoding conversion for diff contents
This commit is contained in:
parent
395188043b
commit
bfaad12cac
2 changed files with 34 additions and 4 deletions
|
@ -59,6 +59,28 @@ class TestRepo(unittest.TestCase):
|
|||
self.assertIn("index", diffs)
|
||||
self.assertIn("workingdir", diffs)
|
||||
|
||||
def test_diffs_with_single_byte_encoding(self):
|
||||
with GitTemporaryDirectory():
|
||||
encoding = "cp1251"
|
||||
|
||||
repo = git.Repo()
|
||||
|
||||
fname = Path("foo.txt")
|
||||
fname.write_text("index\n", encoding=encoding)
|
||||
repo.git.add(str(fname))
|
||||
|
||||
# Make a change with non-ASCII symbols in the working dir
|
||||
fname.write_text("АБВ\n", encoding=encoding)
|
||||
|
||||
git_repo = GitRepo(InputOutput(encoding=encoding), None, ".")
|
||||
diffs = git_repo.get_diffs()
|
||||
|
||||
# check that all diff output can be converted to utf-8 for sending to model
|
||||
diffs.encode("utf-8")
|
||||
|
||||
self.assertIn("index", diffs)
|
||||
self.assertIn("АБВ", diffs)
|
||||
|
||||
def test_diffs_detached_head(self):
|
||||
with GitTemporaryDirectory():
|
||||
repo = git.Repo()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue