gitea/models/repo
Jason Song 82728a7cec
Do not overwrite empty DefaultBranch (#22708)
Fix #21994. 
And fix #19470.

While generating new repo from a template, it does something like
"commit to git repo, re-fetch repo model from DB, and update default
branch if it's empty".


19d5b2f922/modules/repository/generate.go (L241-L253)

Unfortunately, when load repo from DB, the default branch will be set to
`setting.Repository.DefaultBranch` if it's empty:


19d5b2f922/models/repo/repo.go (L228-L233)

I believe it's a very old temporary patch but has been kept for many
years, see:
[2d2d85bb](https://github.com/go-gitea/gitea/commit/2d2d85bb#diff-1851799b06733db4df3ec74385c1e8850ee5aedee70b8b55366910d22725eea8)

I know it's a risk to delete it, may lead to potential behavioral
changes, but we cannot keep the outdated `FIXME` forever. On the other
hand, an empty `DefaultBranch` does make sense: an empty repo doesn't
have one conceptually (actually, Gitea will still set it to
`setting.Repository.DefaultBranch` to make it safer).
2023-02-02 14:48:48 -06:00
..
archiver.go
attachment_test.go
attachment.go
avatar.go
collaboration_test.go
collaboration.go Always reuse transaction (#22362) 2023-01-08 09:34:58 +08:00
fork_test.go
fork.go
git.go
issue.go
language_stats.go
main_test.go
mirror.go Use ErrInvalidArgument in packages (#22268) 2022-12-31 12:49:37 +01:00
pushmirror_test.go
pushmirror.go Use ErrInvalidArgument in packages (#22268) 2022-12-31 12:49:37 +01:00
redirect_test.go
redirect.go
release.go Use ErrInvalidArgument in packages (#22268) 2022-12-31 12:49:37 +01:00
repo_indexer.go
repo_list_test.go Add a simple test for external renderer (#20033) 2022-12-12 20:45:21 +08:00
repo_list.go Fix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454) 2023-01-16 11:25:22 +00:00
repo_test.go
repo_unit.go Implement actions (#21937) 2023-01-31 09:45:19 +08:00
repo.go Do not overwrite empty DefaultBranch (#22708) 2023-02-02 14:48:48 -06:00
star_test.go
star.go
topic_test.go
topic.go
update.go Fix error when calculate the repository size (#22392) 2023-01-13 18:54:02 +00:00
upload.go
user_repo_test.go
user_repo.go
watch_test.go
watch.go
wiki_test.go
wiki.go