Add support for `--rebase-merges` during the rebase process
nicocvn opened this issue · 3 comments
Summary
Add a configuration option to pass --rebase-merges
for rebase operations.
Motivation
From the README:
- Marge-bot rebases the latest target branch (typically master) into the merge-request branch and pushes it. Once the tests have passed and there is a sufficient number of approvals (if a minimal approvals limit has been set on the project), Marge-bot will merge (or rebase, depending on project settings) the merge request via the GitLab API. It can also add some headers to all commits in the merge request as described in the next section.
What we observe in our projects is that this (as expected with git rebase
) wipes out the merge commits.
Our typical workflow with branches is as follows:
- we use a
release/x.y.z
branch to develop a future release; this branch is protected such that changes can only be incorporated via a merge request with review and approvals, - the release development is performed incrementally by merging to the
release/x.y.z
branch (via marge-bot) from short-term branches (e.g.issue/xxx
), - once release development is completed, tested, validated we have to bring it to the
master
branch which is done via a merge request handled by marge-bot.
Because of the rebase operation the merge commits are dropped and the release/x.y.z
becomes a linear branch with all the commits from the various issue/xxx
branches. This is not a show stopper but it would be great to have the option to preserve the structure of the branch.
The --rebase-merges
option is specifically designed for this and was introduced in Git 2.18 (--preserve-merges
seems to now be deprecated).
Hey, could you try this option --use-merge-strategy
and see if that meets your requirements?
We actually did investigate that option but this was creating a merge commit on the source branch and then re-merging it onto the master branch which somewhat breaks our branching strategy.
Is this something you plan to support in the future? Or is there any interest in a PR?
I took a quick look at the code base and it seems that the rebase operation is controlled from here and initiated based on the strategy stored in the "fusion" options of the main app. I could try to make a proof of concept and see if I can make it work but I am a bit unclear on how you would prefer to expose that option (another strategy for rebasing/merging or a sub-option for the rebase strategy).
I have an offline fork that implements this option; I'll try to put up a PR once I clear it with my employer.