RETARGET_CHILDREN_ON_MERGE retargets branches to the main branch instead of the target of the parent branch #14789

Open
opened 2025-11-02 11:23:01 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @Zermelo-Ulbe on GitHub (Jul 21, 2025).

Description

When closing a branch in the middle of a PR chain, the target of the child PR is reset to the main branch instead of the target of the parent PR. This behavior has changed since 1.23.X.

The config cheat sheet says the target of the child branch should be set to the target of the parent branch:

RETARGET_CHILDREN_ON_MERGE: true: Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo.

Reproduction

  • Start Gitea with RETARGET_CHILDREN_ON_MERGE: true
  • Create four branches and main: main, notmain, 1, 2, 3
  • Create a PR from 3 into 2, from 2 into 1, and from 1 into notmain
    • notmain < 1 < 2 < 3
  • Merge the PR from 2 into 1
    • Expected: notmain < 1 < 3
    • Actual: notmain < 1 and main < 3

Repro at https://demo.gitea.com/Zermelo-Ulbe/demo/pulls/3

Gitea Version

1.24.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Image Image Image

Git Version

No response

Operating System

No response

How are you running Gitea?

Issue occurs on https://demo.gitea.com/

Database

None

Originally created by @Zermelo-Ulbe on GitHub (Jul 21, 2025). ### Description When closing a branch in the middle of a PR chain, the target of the child PR is reset to the main branch instead of the target of the parent PR. This behavior has changed since 1.23.X. The config cheat sheet says the target of the child branch should be set to the target of the parent branch: > RETARGET_CHILDREN_ON_MERGE: true: Retarget child pull requests to the parent pull request branch target on merge of parent pull request. It only works on merged PRs where the head and base branch target the same repo. **Reproduction** * Start Gitea with RETARGET_CHILDREN_ON_MERGE: true * Create four branches and main: `main`, `notmain`, `1`, `2`, `3` * Create a PR from `3` into `2`, from `2` into `1`, and from `1` into `notmain` * `notmain < 1 < 2 < 3` * Merge the PR from `2` into `1` * Expected: `notmain < 1 < 3` * Actual: `notmain < 1` and `main < 3` Repro at https://demo.gitea.com/Zermelo-Ulbe/demo/pulls/3 ### Gitea Version 1.24.3 ### Can you reproduce the bug on the Gitea demo site? Yes ### Log Gist _No response_ ### Screenshots <img width="1662" height="528" alt="Image" src="https://github.com/user-attachments/assets/24d206e1-3023-4df2-b943-863c0c9c7ca0" /> <img width="1629" height="932" alt="Image" src="https://github.com/user-attachments/assets/7a3c2f3b-e7e6-4e26-9f4e-3754edcb3d63" /> <img width="1599" height="357" alt="Image" src="https://github.com/user-attachments/assets/e294b749-f0a0-4998-ad2d-733d0e86320d" /> ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? Issue occurs on https://demo.gitea.com/ ### Database None
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 11:23:01 -06:00
Author
Owner

@Zermelo-Ulbe commented on GitHub (Sep 1, 2025):

Hi @delvh I think I might have time to look into this in the coming weeks. Would you be open to a PR?

@Zermelo-Ulbe commented on GitHub (Sep 1, 2025): Hi @delvh I think I might have time to look into this in the coming weeks. Would you be open to a PR?
Author
Owner

@delvh commented on GitHub (Sep 1, 2025):

Sure.
Just send a PR once you came around to implement it

@delvh commented on GitHub (Sep 1, 2025): Sure. Just send a PR once you came around to implement it
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14789