fix(FN-011): catch CalledProcessError in get_status, fix deletion logic, add explicit encoding
Fusion-Task-Id: FN-011 Fusion-Task-Lineage: 4a9aca6f-9d91-43aa-8d2a-d59657c1541a
This commit is contained in:
@@ -52,10 +52,12 @@ class LocalGitOperations(GitOperations):
|
|||||||
if not repo_path.exists() or not (repo_path / ".git").is_dir():
|
if not repo_path.exists() or not (repo_path / ".git").is_dir():
|
||||||
raise RuntimeError("Not a git repository")
|
raise RuntimeError("Not a git repository")
|
||||||
|
|
||||||
|
try:
|
||||||
branch_result = subprocess.run(
|
branch_result = subprocess.run(
|
||||||
["git", "-C", str(repo_path), "branch", "--show-current"],
|
["git", "-C", str(repo_path), "branch", "--show-current"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
branch = branch_result.stdout.strip()
|
branch = branch_result.stdout.strip()
|
||||||
@@ -64,8 +66,11 @@ class LocalGitOperations(GitOperations):
|
|||||||
["git", "-C", str(repo_path), "status", "--porcelain"],
|
["git", "-C", str(repo_path), "status", "--porcelain"],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
except subprocess.CalledProcessError as exc:
|
||||||
|
raise RuntimeError("Git command failed") from exc
|
||||||
|
|
||||||
untracked: list[str] = []
|
untracked: list[str] = []
|
||||||
modified: list[str] = []
|
modified: list[str] = []
|
||||||
@@ -83,7 +88,8 @@ class LocalGitOperations(GitOperations):
|
|||||||
untracked.append(filename)
|
untracked.append(filename)
|
||||||
elif index_status in ("M", "A"):
|
elif index_status in ("M", "A"):
|
||||||
staged.append(filename)
|
staged.append(filename)
|
||||||
elif index_status == "D" or worktree_status == "D":
|
|
||||||
|
if index_status == "D" or worktree_status == "D":
|
||||||
deleted.append(filename)
|
deleted.append(filename)
|
||||||
|
|
||||||
if worktree_status == "M":
|
if worktree_status == "M":
|
||||||
|
|||||||
Reference in New Issue
Block a user