Fixed Git integration
This commit is contained in:
@@ -28,17 +28,17 @@ class GiteaClient:
|
|||||||
repo: str,
|
repo: str,
|
||||||
title: str,
|
title: str,
|
||||||
body: str,
|
body: str,
|
||||||
labels: list[str] | None = None,
|
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
payload: dict[str, Any] = {"title": title, "body": body}
|
|
||||||
if labels:
|
|
||||||
payload["labels"] = labels
|
|
||||||
with self._client() as client:
|
with self._client() as client:
|
||||||
response = client.post(
|
response = client.post(
|
||||||
f"/api/v1/repos/{owner}/{repo}/issues",
|
f"/api/v1/repos/{owner}/{repo}/issues",
|
||||||
json=payload,
|
json={"title": title, "body": body},
|
||||||
|
)
|
||||||
|
if response.is_error:
|
||||||
|
detail = response.text.strip() or response.reason_phrase
|
||||||
|
raise ValueError(
|
||||||
|
f"Gitea issue create failed ({response.status_code}): {detail}"
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def close_issue(self, owner: str, repo: str, issue_number: int) -> dict[str, Any]:
|
def close_issue(self, owner: str, repo: str, issue_number: int) -> dict[str, Any]:
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ class ProjectService:
|
|||||||
branch = f"feature/{story['ref']}-{slugify_branch(title)}"
|
branch = f"feature/{story['ref']}-{slugify_branch(title)}"
|
||||||
gitea_issue_number = None
|
gitea_issue_number = None
|
||||||
gitea_url = ""
|
gitea_url = ""
|
||||||
labels = [issue_type] if issue_type else []
|
|
||||||
|
|
||||||
if binding and self.settings.gitea_configured:
|
if binding and self.settings.gitea_configured:
|
||||||
gitea = GiteaClient()
|
gitea = GiteaClient()
|
||||||
@@ -186,12 +185,13 @@ class ProjectService:
|
|||||||
taiga.story_url(taiga_proj.taiga_id, story["ref"]),
|
taiga.story_url(taiga_proj.taiga_id, story["ref"]),
|
||||||
branch,
|
branch,
|
||||||
)
|
)
|
||||||
|
if issue_type:
|
||||||
|
gitea_body = f"**Тип:** {issue_type}\n\n{gitea_body}"
|
||||||
issue = gitea.create_issue(
|
issue = gitea.create_issue(
|
||||||
binding.gitea_owner,
|
binding.gitea_owner,
|
||||||
binding.gitea_repo,
|
binding.gitea_repo,
|
||||||
title,
|
title,
|
||||||
gitea_body,
|
gitea_body,
|
||||||
labels=labels,
|
|
||||||
)
|
)
|
||||||
gitea_issue_number = issue["number"]
|
gitea_issue_number = issue["number"]
|
||||||
gitea_url = gitea.issue_url(
|
gitea_url = gitea.issue_url(
|
||||||
@@ -229,7 +229,7 @@ class ProjectService:
|
|||||||
"url": gitea_url,
|
"url": gitea_url,
|
||||||
},
|
},
|
||||||
"branch": branch,
|
"branch": branch,
|
||||||
"labels": labels,
|
"issue_type": issue_type,
|
||||||
"subtasks": [{"ref": t.get("ref"), "subject": t.get("subject")} for t in subtasks],
|
"subtasks": [{"ref": t.get("ref"), "subject": t.get("subject")} for t in subtasks],
|
||||||
"questions": structured.get("questions") or [],
|
"questions": structured.get("questions") or [],
|
||||||
"project_slug": taiga_proj.slug,
|
"project_slug": taiga_proj.slug,
|
||||||
|
|||||||
Reference in New Issue
Block a user