34 أسطر
712 B
Python
34 أسطر
712 B
Python
import json
|
|
from helpers import format_error, log
|
|
from api import api_open_pr
|
|
import httpx
|
|
|
|
|
|
def pr_open_tool(
|
|
repo: str,
|
|
title: str,
|
|
head: str,
|
|
base: str,
|
|
body: str = ""
|
|
) -> str:
|
|
try:
|
|
pr = api_open_pr(
|
|
repo,
|
|
title=title,
|
|
head=head,
|
|
base=base,
|
|
body=body
|
|
)
|
|
return json.dumps(
|
|
{
|
|
"status": "success",
|
|
"pr": pr
|
|
},
|
|
ensure_ascii=False
|
|
)
|
|
except httpx.HTTPStatusError as e:
|
|
return format_error("PR open failed", e)
|
|
except Exception as e:
|
|
log.exception("Unexpected error while opening PR")
|
|
return f"{e}"
|