fix: Include default_branch in project export/import

What does this MR do and why?

fix: Include default_branch in project export/import

Add default_branch to export configuration and implement setter method to preserve the default branch setting across project export/import operations. This addresses the issue where default_branch was overlooked when the allowlist approach was introduced in GitLab 14.5.

Changes include:

  • Added default_branch to import_export.yml methods section
  • Implemented default_branch= setter in HasRepository concern
  • Added safe error handling to prevent import failures

References

Screenshots or screen recordings

Source Before After
source before after

How to set up and validate locally

  • In a project, create a branch with a name later in the alphabetical order then the default branch.
  • Export the project via Settings > General > Advanced > Export Project
  • Refresh the page until the file is available to download then download it
  • Import the project New Project > Import Project > Gitlab Import >
  • Observe incorrect default branch assignment
  • Check out into the 342246-include-default-branch-config
  • Re-export the project
  • Import the project
  • Observe correct default branch assignment

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #342246

Edited by Carla Drago

Merge request reports

Loading