Rename default_branch_or_master to default_branch_or_main [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Merged Igor Drozdov requested to merge id-rename-default_branch_or_master into master

What does this MR do?

Related issue: https://gitlab.com/gitlab-org/gitlab/-/issues/323925

Let's rename the method and return main when default branch is not set.

In most cases it shouldn't change the product behavior because the default branch logic is provided by Gitaly and if master exists in the repo, the branch will be returned: gitaly@891fd307.

But in the cases when a project is empty, Gitaly returns nil as a default branch, so we can control it by ourselves and force main instead. When the first branch is created, Gitaly returns this first branch as a default one and then it's set by Gitlab Rails as default: https://gitlab.com/gitlab-org/gitlab/-/blob/065153e6bd1983ece6f1f7d188e5f29e3c1844b7/app/services/git/branch_hooks_service.rb#L70.

User facing changes

For example, when a project is empty, the Add README (and other) buttons will create a file in main branch by default:

Screenshot_2021-04-26_at_10.46.49

Edited by Igor Drozdov