gitbutler icon indicating copy to clipboard operation
gitbutler copied to clipboard

GitLab: use merge request dependency for stacked MRs

Open nolith opened this issue 8 months ago • 2 comments

I enjoy the stacked branches feature, now that PRs landed on GitLab I can see a missing feature compared to what I used to do in the past when I had to create my merge requests manually.

In GitLab (Premium and Ultimate) you can declare merge request dependencies. When creating a stack I set each MR as depending on the one before.

The effect of this is that you must merge the stack from the bottom, and as you merge each MR, the next one will automatically change its target branch from the previous MR to the default branch.

MR dependencies can be set with a simple API call and it will return a 403 error if the project doesn't have at least a Premium license.

nolith avatar Apr 18 '25 08:04 nolith

Thanks so much for sharing, using this feature would make stacked PRs quite a bit more convenient on GitLab.

Making such an API call and making it optional (as in "may fail silently") should do the trick.

Byron avatar Apr 18 '25 18:04 Byron

@Byron I took a deeper look at this matter and there is another element that is necessary to make stacked MRs work as intended (on GitLab). We also need to auto-remove the branch when the MR is merged, it's just an API parameter for the MR creation #8222

So when you merge the first MR in a stack, it will auto-delete the source branch and trigger an update of the next MR in the stack to target the default branch.

nolith avatar Apr 22 '25 13:04 nolith