go-gitea/gitea

Merging a PR via the API does not honor the `Delete pull request branch after merge by default` setting

Closed this issue · 0 comments

Description

When merging a PR using the /api/v1/repos/{owner}/{repo}/pulls/{index}/merge endpoint, the PR source branch does not get deleted when Delete pull request branch after merge by default is set in the repository settings.

I called the API using curl -H 'authorization: token <token>' -H 'content-type: application/json' --data '{"Do":"merge"}' https://gitea.example.com/api/v1/repos/vbrandl/test-api-merge/pulls/1/merge and the PR got merged, but the branch does not get deleted.

Steps to reproduce:

  1. create a repository
  2. create a PR
  3. set Delete pull request branch after merge by default in repository settings
  4. try merging using the API

Expected behavior: the PR source branch should get deleted

Actual behavior: the PR source branch does not get deleted

I reproduced the issue in https://demo.gitea.com/vbrandl/test-api-merge/pulls/1 using the following API call:

$ curl -i -H 'authorization: token <snip>' -H 'content-type: application/json' --data '{"Do":"merge"}' https://demo.gitea.com/api/v1/repos/vbrandl/test-api-merge/pulls/1/merge
HTTP/2 200
alt-svc: h3=":443"; ma=2592000
cache-control: max-age=0, private, must-revalidate, no-transform
date: Thu, 11 Sep 2025 15:11:01 GMT
server: Caddy
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
content-length: 0

Gitea Version

1.24.5

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Reproduced on demo.gitea.com and my selfhosted instance running on gitea/gitea:latest

Database

PostgreSQL