marge-bot icon indicating copy to clipboard operation
marge-bot copied to clipboard

Batching Merge Requests doesn't work for forking workflow

Open sg70 opened this issue 3 years ago • 1 comments

Marge-bot assumes during batching merge requests that the source branch is the origin repo when fusing the MR. The source branch is not the origin repo when using the forking workflow. The results in an error message "merge: origin/source-branch - not something we can merge"

marge-bot version: 0.9.5

sg70 avatar Apr 22 '21 19:04 sg70

So to me with bot 0.9.4, and I modify some code here, it maybe works

index a4b3479..d022ab3 100644
--- a/marge/batch_job.py
+++ b/marge/batch_job.py
@@ -110,17 +110,20 @@ class BatchMergeJob(MergeJob):
             if getattr(changed_mr, attr) != getattr(merge_request, attr):
                 raise CannotMerge(error_message.format(attr.replace('_', ' ')))
 
-    def merge_batch(self, target_branch, source_branch, no_ff=False):
+    def merge_batch(self, target_branch, source_branch, no_ff=False, source_repo_url=None, local=False):
         if no_ff:
             return self._repo.merge(
-                    target_branch,
-                    source_branch,
-                    '--no-ff',
+                target_branch,
+                source_branch,
+                '--no-ff',
+                source_repo_url,
+                local
             )
-
         return self._repo.fast_forward(
             target_branch,
             source_branch,
+            source_repo_url,
+            local
         )
 
     def update_merge_request(
@@ -177,6 +180,8 @@ class BatchMergeJob(MergeJob):
             merge_request.target_branch,
             merge_request.source_branch,
             self._options.use_no_ff_batches,
+            source_repo_url,
+            merge_request.source_project_id == merge_request.source_project_id
         )
         # Don't force push in case the remote has changed.
         self._repo.push(merge_request.target_branch, force=False)

see also: https://github.com/bigc2000/marge-bot/tree/wx-forked-project

bigc2000 avatar May 10 '21 20:05 bigc2000