Skip to content

Fix wrong default branch imported with Bitbucket Server

Stan Hu requested to merge sh-fix-bitbucket-server-importer-default-branch into master

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

  1. Install Bitbucket Server.
  2. Create a project by importing an existing one (e.g. I chose https://gitlab.com/gitlab-org/gitlab-shell).
  3. In the Bitbucket Server project settings, change the default branch to something other than main (I chose 13-15-stable):

image

  1. In GitLab, attempt to import this project via the Bitbucket Server importer
  2. Visit the project:

image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Stan Hu

Merge request reports

Loading