الملفات
GitPasha-MCP-Server/tools/issue_update.py

50 أسطر
1.2 KiB
Python

import json
from helpers import format_error, log
from api import api_update_issue
import httpx
def issue_update_tool(
repo: str,
issue: str,
title: str = "",
body: str = "",
state: str = "",
labels_csv: str = "",
assignees_csv: str = "",
comment: str = "",
) -> str:
try:
labels = [
x.strip() for x in labels_csv.split(",") if x.strip()
] if labels_csv else None
assignees = [
x.strip() for x in assignees_csv.split(",") if x.strip()
] if assignees_csv else None
st = state or None
t = title or None
b = body or None
c = comment or None
out = api_update_issue(
repo,
issue,
title=t,
body=b,
state=st,
labels=labels,
assignees=assignees,
comment=c
)
return json.dumps(
{
"status": "success",
"result": out
},
ensure_ascii=False
)
except httpx.HTTPStatusError as e:
return format_error("Issue update failed", e)
except Exception as e:
log.exception("Unexpected error while updating issue")
return f"{e}"