# \[Bug\]: Forgejo merges ignore the repository's delete-branch-after-merge setting · Issue \#14296 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/issues/14296)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: completed

Priority: 0

## Description

[Discussion and activity](https://git.cafe/pingdotgg/t3code/issues/14296)

---

### Before submitting

- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to investigate the problem.

### Area

apps/server

### Steps to reproduce

1. Enable the default deletion of pull request branches after merge in a Forgejo repository's settings.
2. Merge a pull request through T3 Code's Pull Requests interface.
3. Check whether the source branch remains in Forgejo.

### Expected behavior

T3 Code respects the target repository's `default_delete_branch_after_merge` setting when merging.
When enabled, request branch deletion through Forgejo's merge endpoint; when disabled, retain the branch.
Forgejo should enforce its own branch protection and deletion permissions.

### Actual behavior

The source branch is retained.
Code inspection on upstream `27bdf1aa1` confirms that `ForgejoPullRequestProvider.runAction` sends only `{ Do: input.mergeMethod ?? "merge" }` to `POST /repos/{owner}/{repo}/pulls/{number}/merge`.
It never supplies `delete_branch_after_merge`, and the `ForgejoRepository` decoder does not include `default_delete_branch_after_merge`.

### Suggested fix

Read the target repository's current setting before submitting the merge and include `delete_branch_after_merge` in the merge request.
Keep branches when the optional setting is absent, and do not proceed with a merge if reading the repository settings fails.
Cover enabled, disabled, missing, and failed settings reads with focused regression tests.

### Verification

Reported behavior verified against the current merge implementation; no live repository was merged or modified during investigation.

### Version or commit

Upstream main at `27bdf1aa1`.
