git-backporting icon indicating copy to clipboard operation
git-backporting copied to clipboard

Allow enabling "Delete source branch when merge request accepted"

Open peat-psuwit opened this issue 10 months ago • 2 comments

Is your feature request related to a problem? Please describe. I would prefer that the backported MR's branch be deleted automatically. This is possible via GitLab's "Delete source branch when merge request accepted" settings. This is exposed in the API as remove_source_branch.

Describe the solution you'd like When configured as so, set attribute remove_source_branch as part of a request to POST /projects/:id/merge_requests. However, I'm not sure if there's the equivalent thing in GitHub, and as such I'm not sure how to model config. Maybe just documentation (that a config is GitLab only) is enough?

Describe alternatives you've considered

  • We can manually select "Delete source branch" just before pressing "Merge". However this is prone to forgetting.
  • We can parse the program's output to fish out the MR address from the log and then manually send PUT /projects/:id/merge_requests/:merge_request_iid. However, this can be prone to breakage.

peat-psuwit avatar Apr 08 '24 20:04 peat-psuwit

Hi @peat-psuwit , this is for sure an interesting improvement!!

However, I'm not sure if there's the equivalent thing in GitHub

I don't know either, but I can find some time to investigate this on Github side.

Maybe just documentation (that a config is GitLab only) is enough?

I'd try to keep all clients feature-equivalents but if there are no ways on Github and for Gitlab it is as easy as you highlighted, yeah we can consider document that this would be a Gitlab-only feature

lampajr avatar Apr 08 '24 20:04 lampajr

We can manually select "Delete source branch" just before pressing "Merge". However this is prone to forgetting. We can parse the program's output to fish out the MR address from the log and then manually send PUT /projects/:id/merge_requests/:merge_request_iid. However, this can be prone to breakage.

Another workaround, a bit more trickier (but I saw some repo using it) is to setup an additional workflow to cleanup backport branches if the corresponding PR/MR is merged, e.g., https://github.com/infinispan/infinispan/blob/main/.github/workflows/backport_reaper.yaml

lampajr avatar Apr 08 '24 20:04 lampajr