Skip to content

Show the default "default branch" in the API for empty projects

What does this MR do?

Where someone has configured a default branch, it's confusing for the API to return nil for empty projects here. It also makes it difficult for them to build automation around arbitrary default branches.

Returning the expected default branch name should resolve these issues.

This change only affects projects with no repository, or an empty repository. Currently we return nil in those cases, but it's easy to return the value that the default branch would be, if it exists, since we store that in the database (a value like main, master, or develop, for instance. It may be configured at group or instance level). It's accessible as project.default_branch_or_main.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #330622 (closed)

Edited by Nick Thomas

Merge request reports