Fix wrong default branch imported with Bitbucket Server
What does this MR do and why?
When importing a repository from Bitbucket Server where HEAD of that repo is something different than the default HEAD as created by Gitaly (which currently is "main", so it would be triggered by importing any repo whose HEAD points to "master"), then the end result is a corrupt repository. This is because the import will create repos by first calling CreateRepository, which initializes HEAD to "main", and then calling FetchRemote, which only fetches refs but won't ever update HEAD.
We fix this by doing a standard import of the repository with a follow-up fetch to map the pull requests to merge request references.
Relates to #346008 (closed)
How to set up and validate locally
- Install Bitbucket Server.
- Create a project by importing an existing one (e.g. I chose https://gitlab.com/gitlab-org/gitlab-shell).
- In the Bitbucket Server project settings, change the default branch to something other than
main
(I chose13-15-stable
):
- In GitLab, attempt to import this project via the Bitbucket Server importer
- Visit the project:
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.