DefaultBranch is not set correctly when using template which has 'master' as default #19470
Labels
issue/confirmed
Issue has been reviewed and confirmed to be present or accepted to be implemented
issue/workaround
it is or has a workaround
type/bug
Milestone
Description
In #19354 the default branch for new repositories was changed from 'master' to 'main'. When running this new version on existing data where 'master' was still used as default this causes a problem when creating a new repository from a template which still uses 'master'.
The files and master branch are correctly copied to the newly generated repository however giteas internal default branch is set to 'main' instead of 'master'. This causes giteas "Branches" page to remain blank despite showing 1 branch and when cloning the repository git shows
warning: remote HEAD refers to nonexistent ref, unable to checkout.
.When opening the "Branches" page gitea throws an error:
2022/04/23 10:48:22 ...s/web/repo/branch.go:177:loadBranches() [W] [6263bd56] loadBranches: missing default branch main for 60:sschroe/template_test
Example of a broken repo on the demo site: https://try.gitea.io/steffen/template_test/branches
To reproduce:
Gitea Version
9550e5a
Can you reproduce the bug on the Gitea demo site?
Yes
Log Gist
No response
Screenshots
No response
Git Version
2.36.0
Operating System
Arch Linux
How are you running Gitea?
git clone': git clone --recursive https://github.com/go-gitea/gitea.git
cd gitea
TAGS="bindata sqlite sqlite_unlock_notify" make build
./gitea
Database
SQLite
The text was updated successfully, but these errors were encountered: