From fd056e3ed0cdc55230898570488c170654b3f913 Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 30 Jun 2026 22:01:44 +0200 Subject: [PATCH] feat: add merge_pull_request to GiteaClient (#3) --- gitea/client.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gitea/client.py b/gitea/client.py index c822950..73cb119 100644 --- a/gitea/client.py +++ b/gitea/client.py @@ -429,3 +429,22 @@ class GiteaClient(IssuesClient, PullRequestsClient, FilesClient, RefsClient, Rep except Exception as e: print(f"Error marking notification thread {thread_id} as read: {e}") return False + + def merge_pull_request( + self, owner: str, repo: str, pull_number: int, style: str = "squash", title: str = "", message: str = "" + ) -> bool: + try: + with httpx.Client() as client: + url = f"{self.base_url}/api/v1/repos/{owner}/{repo}/pulls/{pull_number}/merge" + data: dict[str, Any] = { + "Do": style, + "MergeTitleField": title, + "MergeMessageField": message, + } + response = client.post(url, headers=self.headers, json=data) + response.raise_for_status() + return True + except Exception as e: + print(f"Error merging pull request {pull_number}: {e}") + raise +