Mirrored Open MR Requests from Bitbucket to Gitlab Do Not Mirror Git Refs
Summary
When importing a new repository from a mirrored Bitbucket server-type into GitLab, the git refs of open MRs are not present.
Steps to reproduce
In Bitbucket:
- create new repo.
- commit something.
- create a pull-request (and leave open).
In Gitlab:
- Create a new project from import from Bitbucket server
- Run
gitlab-rails
commands to observe the lack ofmerge
/ pull-request refs.
Example Project
https://gitlab.com/gyoachum/a-test-repo/-/merge_requests
What is the current bug behavior?
The refs are not present and as a result the MR has to be closed and then re-openen to generate the refs needed.
What is the expected correct behavior?
The refs should be imported with the rest of the repo. If they can't be imported, then the refs should be created without the need to close and then re-open the MR.
Relevant logs and/or screenshots
This is what it looks like in the rails console:
irb(main):005:0> proj = Project.find_by(id: 9)
=> #<Project id:9 root/a-test-repo>>
irb(main):006:0> mr = proj.merge_requests.find_by_iid('1')
=> #<MergeRequest id:5 root/a-test-repo!1>
irb(main):007:0> proj.repository.branch_exists?(mr.target_branch)
=> true
irb(main):009:0> proj.repository.branch_exists?(mr.source_branch)
=> true
irb(main):010:0> pp proj.disk_path
"@hashed/19/58/19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03f7c3017bb5b7"
=> "@hashed/19/58/19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03f7c3017bb5b7"
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/19/58/19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03f7c3017bb5b7.git/refs/merge-requests# ls -alrt 1/
total 12
drwxr-sr-x 3 git git 4096 Feb 24 20:03 ..
-rw-r--r-- 1 git git 41 Feb 24 20:03 merge
drwxr-sr-x 2 git git 4096 Feb 24 20:03 .
When it should actually look like this (after I closed and re-opened the mirrored MR):
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5.git/refs# ls -alrt
total 24
drwxr-sr-x 2 git git 4096 Feb 24 20:19 tags
drwxr-sr-x 2 git git 4096 Feb 24 20:19 heads
drwxr-s--- 6 git git 4096 Feb 24 20:19 ..
drwxr-sr-x 3 git git 4096 Feb 24 20:29 merge-requests
drwxr-sr-x 6 git git 4096 Feb 24 20:29 .
drwxr-sr-x 2 git git 4096 Feb 24 20:29 keep-around
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5.git/refs# ls -alrt merge-requests/1/
total 16
drwxr-sr-x 3 git git 4096 Feb 24 20:29 ..
-rw-r--r-- 1 git git 41 Feb 24 20:29 merge
-rw-r--r-- 1 git git 41 Feb 24 20:29 head
drwxr-sr-x 2 git git 4096 Feb 24 20:29 .
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5.git/refs# ls -alrt merge-requests/1/head
heads/ keep-around/ merge-requests/ tags/
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5.git/refs# ls -alrt merge-requests/1/head
-rw-r--r-- 1 git git 41 Feb 24 20:29 merge-requests/1/head
root@gabe-gitlab:/var/opt/gitlab/git-data/repositories/@hashed/4a/44/4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6af1dd5.git/refs# cat merge-requests/1/head
af858ac8f9a973f938bc1a25f988bc4345035450
Output of checks
This bug happens on GitLab.com
Possible fixes
In my testing, I got the idea from this stackoverflow page to add the line fetch = +refs/pull-requests/*:refs/pull-requests/*
to my Bitbucket repo .git/config
but it did not seem to help at all: