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,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":
|
||||
|
||||
Reference in New Issue
Block a user