添加 encoding 参数以确保 Git 命令输出正确编码
This commit is contained in:
parent
2db6ce13eb
commit
36ef93f4f2
|
|
@ -13,6 +13,7 @@ class GitHandler:
|
||||||
self.llm_client = llm_client
|
self.llm_client = llm_client
|
||||||
else:
|
else:
|
||||||
from .llm import LLMClient
|
from .llm import LLMClient
|
||||||
|
|
||||||
self.llm_client = LLMClient()
|
self.llm_client = LLMClient()
|
||||||
|
|
||||||
def get_diff(self) -> str:
|
def get_diff(self) -> str:
|
||||||
|
|
@ -21,7 +22,8 @@ class GitHandler:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["git", "diff", "--staged"],
|
["git", "diff", "--staged"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
return result.stdout
|
return result.stdout
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
|
@ -35,7 +37,8 @@ class GitHandler:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["git", "commit", "-m", message],
|
["git", "commit", "-m", message],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception(f"Git 提交失败: {result.stderr}")
|
raise Exception(f"Git 提交失败: {result.stderr}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue