添加 encoding 参数以确保 Git 命令输出正确编码

This commit is contained in:
songsenand 2026-02-04 16:42:29 +08:00
parent 2db6ce13eb
commit 36ef93f4f2
1 changed files with 5 additions and 2 deletions

View File

@ -13,6 +13,7 @@ class GitHandler:
self.llm_client = llm_client
else:
from .llm import LLMClient
self.llm_client = LLMClient()
def get_diff(self) -> str:
@ -21,7 +22,8 @@ class GitHandler:
result = subprocess.run(
["git", "diff", "--staged"],
capture_output=True,
text=True
text=True,
encoding="utf-8",
)
return result.stdout
except FileNotFoundError:
@ -35,7 +37,8 @@ class GitHandler:
result = subprocess.run(
["git", "commit", "-m", message],
capture_output=True,
text=True
text=True,
encoding="utf-8",
)
if result.returncode != 0:
raise Exception(f"Git 提交失败: {result.stderr}")