Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batching Merge Requests doesn't work for forking workflow #302

Open
sg70 opened this issue Apr 22, 2021 · 1 comment · May be fixed by #307
Open

Batching Merge Requests doesn't work for forking workflow #302

sg70 opened this issue Apr 22, 2021 · 1 comment · May be fixed by #307

Comments

@sg70
Copy link
Contributor

sg70 commented Apr 22, 2021

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

@bigc2000
Copy link

bigc2000 commented May 10, 2021

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

@qqshfox qqshfox linked a pull request May 11, 2021 that will close this issue
sg70 added a commit to sg70/marge-bot that referenced this issue Oct 1, 2021
Since all forked MRs are prepared to local branches, the MR
acceptance procedure needs to be also local.

* fix batching MRs when source branch has different repo url
* fix unit tests
* add unit test for use case forked MRs
* remove credentials from debug log

Changes:
/tmpiq7raaob/tmpb84bjxf0 # git merge origin/dummy21 --ff --ff-only
merge: origin/dummy21 - not something we can merge

Into:
/tmpiq7raaob/tmpb84bjxf0 # git merge dummy21 --ff --ff-only
Updating b51f541..9525b89
Fast-forward
 21 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 21

Signed-off-by: Sascha Binckly <[email protected]>
sg70 added a commit to sg70/marge-bot that referenced this issue Mar 30, 2022
Since all forked MRs are prepared to local branches, the MR
acceptance procedure needs to be also local.

* fix batching MRs when source branch has different repo url
* fix unit tests
* add unit test for use case forked MRs
* remove credentials from debug log

Changes:
/tmpiq7raaob/tmpb84bjxf0 # git merge origin/dummy21 --ff --ff-only
merge: origin/dummy21 - not something we can merge

Into:
/tmpiq7raaob/tmpb84bjxf0 # git merge dummy21 --ff --ff-only
Updating b51f541..9525b89
Fast-forward
 21 | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 21

Signed-off-by: Sascha Binckly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants