Refactor legacy git init (#20376)

* merge `CheckLFSVersion` into `InitFull` (renamed from `InitWithSyncOnce`)
* remove the `Once` during git init, no data-race now
* for doctor sub-commands, `InitFull` should only be called in initialization stage

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
wxiaoguang 2022-08-09 11:22:24 +08:00 committed by GitHub
parent 820031e556
commit 75d96f4a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 63 additions and 149 deletions

View file

@ -14,7 +14,6 @@ import (
git_model "code.gitea.io/gitea/models/git"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/lfs"
"code.gitea.io/gitea/modules/setting"
@ -83,11 +82,6 @@ func checkResponseTestContentEncoding(t *testing.T, content *[]byte, resp *httpt
func TestGetLFSSmall(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
content := []byte("A very small file\n")
resp := storeAndGetLfs(t, &content, nil, http.StatusOK)
@ -96,11 +90,6 @@ func TestGetLFSSmall(t *testing.T) {
func TestGetLFSLarge(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
content := make([]byte, web.GzipMinSize*10)
for i := range content {
content[i] = byte(i % 256)
@ -112,11 +101,6 @@ func TestGetLFSLarge(t *testing.T) {
func TestGetLFSGzip(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
b := make([]byte, web.GzipMinSize*10)
for i := range b {
b[i] = byte(i % 256)
@ -133,11 +117,6 @@ func TestGetLFSGzip(t *testing.T) {
func TestGetLFSZip(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
b := make([]byte, web.GzipMinSize*10)
for i := range b {
b[i] = byte(i % 256)
@ -156,11 +135,6 @@ func TestGetLFSZip(t *testing.T) {
func TestGetLFSRangeNo(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
content := []byte("123456789\n")
resp := storeAndGetLfs(t, &content, nil, http.StatusOK)
@ -169,11 +143,6 @@ func TestGetLFSRangeNo(t *testing.T) {
func TestGetLFSRange(t *testing.T) {
defer prepareTestEnv(t)()
git.CheckLFSVersion()
if !setting.LFS.StartServer {
t.Skip()
return
}
content := []byte("123456789\n")
tests := []struct {