Skip to content

Support full refs in default_branch for Projects API

What does this MR do and why?

Contributes to #516857

Problem

The Projects API doesn’t support full references for the default_branch setting when creating a project via the Projects API. This leads to a non-initialized state.

Solution

Allow the default_branch parameter to accept fully qualified references (e.g., refs/heads/main) and automatically convert them to branch names (e.g., main).

References

API: Creating a Project with a full ref as Defa... (#516857)

How to set up and validate locally

  1. Provide token and create a project via REST API
curl --request POST --header "PRIVATE-TOKEN: <your-token>" \
     --header "Content-Type: application/json" --data '{
        "name": "default_branch_project", "description": "New Project", "path": "default_branch_project", "default_branch": "refs/heads/custom_main",
        "namespace_id": "1", "initialize_with_readme": "true"}' \
     --url "http://gdk.test:3000/api/v4/projects/"
  1. Visit new project.
  2. You should see a default branch named custom_main

Screenshot_2025-09-15_at_15.28.50

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 #516857

Edited by Vasilii Iakliushin

Merge request reports

Loading