From ea30f28edbee025ad4afd5f4ec6d196bc2821207 Mon Sep 17 00:00:00 2001 From: Fusion Date: Thu, 14 May 2026 08:15:14 +0200 Subject: [PATCH] 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 --- apps/api/app/git/operations.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/apps/api/app/git/operations.py b/apps/api/app/git/operations.py index ea2057e..2b4f145 100644 --- a/apps/api/app/git/operations.py +++ b/apps/api/app/git/operations.py @@ -52,20 +52,25 @@ class LocalGitOperations(GitOperations): if not repo_path.exists() or not (repo_path / ".git").is_dir(): raise RuntimeError("Not a git repository") - branch_result = subprocess.run( - ["git", "-C", str(repo_path), "branch", "--show-current"], - capture_output=True, - text=True, - check=True, - ) - branch = branch_result.stdout.strip() + try: + branch_result = subprocess.run( + ["git", "-C", str(repo_path), "branch", "--show-current"], + capture_output=True, + text=True, + encoding="utf-8", + check=True, + ) + branch = branch_result.stdout.strip() - status_result = subprocess.run( - ["git", "-C", str(repo_path), "status", "--porcelain"], - capture_output=True, - text=True, - check=True, - ) + status_result = subprocess.run( + ["git", "-C", str(repo_path), "status", "--porcelain"], + capture_output=True, + text=True, + encoding="utf-8", + check=True, + ) + except subprocess.CalledProcessError as exc: + raise RuntimeError("Git command failed") from exc untracked: list[str] = [] modified: list[str] = [] @@ -83,7 +88,8 @@ class LocalGitOperations(GitOperations): untracked.append(filename) elif index_status in ("M", "A"): staged.append(filename) - elif index_status == "D" or worktree_status == "D": + + if index_status == "D" or worktree_status == "D": deleted.append(filename) if worktree_status == "M":