You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/models
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).
1 year ago
..
actions Fix ref to trigger Actions (#22679) 1 year ago
activities Don't return duplicated users who can create org repo (#22560) 1 year ago
admin Implement FSFE REUSE for golang files (#21840) 2 years ago
asymkey Improve error report when user passes a private key (#22726) 1 year ago
auth Support scoped access tokens (#20908) 1 year ago
avatars Fix get system setting bug when enabled redis cache (#22295) 2 years ago
db some refactor about code comments (#20821) 1 year ago
dbfs Add some comments for recent code (#22725) 1 year ago
fixtures Do not overwrite empty DefaultBranch (#22708) 1 year ago
git Add cron method to gc LFS MetaObjects (#22385) 1 year ago
issues Small refactor for loading PRs (#22652) 1 year ago
migrations Implement actions (#21937) 1 year ago
organization Don't return duplicated users who can create org repo (#22560) 1 year ago
packages Add Conda package registry (#22262) 1 year ago
perm Rename almost all Ctx functions (#22071) 2 years ago
project Project links should use parent link methods (#22587) 1 year ago
pull refactor some functions to support ctx as first parameter (#21878) 2 years ago
repo Do not overwrite empty DefaultBranch (#22708) 1 year ago
secret Secrets storage with SecretKey encrypted (#22142) 2 years ago
system Set disable_gravatar/enable_federated_avatar when offline mode is true (#22479) 1 year ago
unit Implement actions (#21937) 1 year ago
unittest Implement actions (#21937) 1 year ago
user Implement actions (#21937) 1 year ago
webhook Support system hook API (#14537) 1 year ago
error.go Implement FSFE REUSE for golang files (#21840) 2 years ago
fixture_generation.go Implement FSFE REUSE for golang files (#21840) 2 years ago
fixture_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
main_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
migrate.go Check primary keys for all tables and drop ForeignReference (#21721) 2 years ago
migrate_test.go Check primary keys for all tables and drop ForeignReference (#21721) 2 years ago
org.go refactor some functions to support ctx as first parameter (#21878) 2 years ago
org_team.go Supports wildcard protected branch (#20825) 1 year ago
org_team_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
org_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo.go Implement actions (#21937) 1 year ago
repo_collaboration.go refactor some functions to support ctx as first parameter (#21878) 2 years ago
repo_collaboration_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_transfer.go Always reuse transaction (#22362) 1 year ago
repo_transfer_test.go Rename almost all Ctx functions (#22071) 2 years ago
user.go Supports wildcard protected branch (#20825) 1 year ago