smarkets / marge-bot

A merge-bot for GitLab
BSD 3-Clause "New" or "Revised" License
701 stars 136 forks source link

Fix merging action when last source commit is not last target commit (gitlab_rebase) #378

Closed wites342 closed 1 year ago

wites342 commented 1 year ago

Requirements :

Merging strategy of GitLab project to perform merge on is set to Fast forward. Marge bot merge strategy is set to Fusion.gitlab_rebase with MARGE_REBASE_REMOTELY env variable.

GitLab merge request project to perform merging action on failure replication steps:

Repository: https://gitlab.com/futuresolutions1/test-merging-functionality 1) git checkout origin/main 2) git checkout -b successful-merging-scenario 3) git reset --hard HEAD~1 4) add any new file with content and commit it 5) git merge main 6) git push

Failing scenario:

_marge-bot executor implementation mr: https://gitlab.com/futuresolutions1/marge-bot-executor/-/merge_requests/7_

Simulates error occured when performed merge action with marge-bot mirrored from base repository: marge-bot.

Merge request used to perform failed merge:

https://gitlab.com/futuresolutions1/test-merging-functionality/-/merge_requests/9 (on merge request description included issue replication steps)

Issue description:

Merging strategy of project to perform merge on is set to Fast forward. Marge bot merge strategy is set to Fusion.gitlab_rebase with MARGE_REBASE_REMOTELY env variable. Source failed-merging-scenario-case branch contains all changes from target main. Changes reflection was performed with manual git merge and then pushed to merge request. Then marge-bot under its execution is trying to perform rebasing again because current implementation expects, that last commit on source branch will be also last comit on target branch. Execution fails because changes are already contained inside source branch. This results in retry of merging action which is failing again. This will be retried in loop until execution will achieve its timeout.

Example failing pipeline execution: https://gitlab.com/futuresolutions1/marge-bot-executor/-/pipelines/946449209

Successful scenario after implementation change:

_marge-bot executor implementation mr: https://gitlab.com/futuresolutions1/marge-bot-executor/-/merge_requests/8_

Simulates successfully performed merge action with marge-bot mirrored from fixed repository implementation: custom-marge-bot.

Merge request used to perform successful merge:

https://gitlab.com/futuresolutions1/test-merging-functionality/-/merge_requests/10 (on merge request description included issue replication steps)

Issue description:

Merging strategy of project to perform merge on is set to Fast forward. Marge bot merge strategy is set to Fusion.gitlab_rebase with MARGE_REBASE_REMOTELY env variable. Source successful-merging-scenario-case branch contains all changes from target main. Changes reflection was performed with manual git merge and then pushed to merge request. Then marge-bot correctly performs merge action and successfully finish its execution.

Example successfull pipeline execution: https://gitlab.com/futuresolutions1/marge-bot-executor/-/jobs/4747540137

wites342 commented 1 year ago

Issue moved to marge-org comminity gitlab repository: https://gitlab.com/marge-org/marge-bot/-/issues/392 https://gitlab.com/marge-org/marge-bot/-/merge_requests/408