diff options
author | Jason Song <i@wolfogre.com> | 2023-02-03 04:48:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-02 14:48:48 -0600 |
commit | 82728a7cecfe4d254890545fea49d6afde4f40db (patch) | |
tree | 9945d45486350e318ce5d31dfe2823d5746743fa /models/fixtures/gpg_key_import.yml | |
parent | 2914c5299b37c3f98997fc923b0b715c9b3f750a (diff) | |
download | gitea-82728a7cecfe4d254890545fea49d6afde4f40db.tar.gz gitea-82728a7cecfe4d254890545fea49d6afde4f40db.zip |
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".
https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/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:
https://github.com/go-gitea/gitea/blob/19d5b2f922c2defde579a935fbedb680eb8fff18/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).
Diffstat (limited to 'models/fixtures/gpg_key_import.yml')
0 files changed, 0 insertions, 0 deletions