aboutsummaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-08-09 11:22:24 +0800
committerGitHub <noreply@github.com>2022-08-09 11:22:24 +0800
commit75d96f4a0274c5b7566305d494c176e1a88b1589 (patch)
treed4dc134d9fea8f0f89f895e7bf30ec39146edf32 /integrations
parent820031e556af9548aa07e4de2669ca52bd7f63cb (diff)
downloadgitea-75d96f4a0274c5b7566305d494c176e1a88b1589.tar.gz
gitea-75d96f4a0274c5b7566305d494c176e1a88b1589.zip
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>
Diffstat (limited to 'integrations')
-rw-r--r--integrations/git_test.go15
-rw-r--r--integrations/integration_test.go5
-rw-r--r--integrations/lfs_getobject_test.go31
-rw-r--r--integrations/migration-test/migration_test.go3
4 files changed, 5 insertions, 49 deletions
diff --git a/integrations/git_test.go b/integrations/git_test.go
index d6bd673822..f9e1eafb65 100644
--- a/integrations/git_test.go
+++ b/integrations/git_test.go
@@ -156,11 +156,6 @@ func standardCommitAndPushTest(t *testing.T, dstPath string) (little, big string
func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS string) {
t.Run("LFS", func(t *testing.T) {
defer PrintCurrentTest(t)()
- git.CheckLFSVersion()
- if !setting.LFS.StartServer {
- t.Skip()
- return
- }
prefix := "lfs-data-file-"
err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("install").Run(&git.RunOpts{Dir: dstPath})
assert.NoError(t, err)
@@ -226,7 +221,6 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
assert.Equal(t, littleSize, resp.Length)
- git.CheckLFSVersion()
if setting.LFS.StartServer {
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS))
resp := session.MakeRequest(t, req, http.StatusOK)
@@ -268,12 +262,9 @@ func mediaTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS
resp := session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
assert.Equal(t, littleSize, resp.Length)
- git.CheckLFSVersion()
- if setting.LFS.StartServer {
- req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS))
- resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
- assert.Equal(t, littleSize, resp.Length)
- }
+ req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", littleLFS))
+ resp = session.MakeRequestNilResponseRecorder(t, req, http.StatusOK)
+ assert.Equal(t, littleSize, resp.Length)
if !testing.Short() {
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/media/branch/master/", big))
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index 230f780175..3c379f5c84 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -175,10 +175,9 @@ func initIntegrationTest() {
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
_ = util.RemoveAll(repo_module.LocalCopyPath())
- if err := git.InitOnceWithSync(context.Background()); err != nil {
+ if err := git.InitFull(context.Background()); err != nil {
log.Fatal("git.InitOnceWithSync: %v", err)
}
- git.CheckLFSVersion()
setting.InitDBConfig()
if err := storage.Init(); err != nil {
@@ -285,7 +284,6 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
assert.NoError(t, unittest.LoadFixtures())
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
- assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
if err != nil {
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
@@ -586,7 +584,6 @@ func resetFixtures(t *testing.T) {
assert.NoError(t, unittest.LoadFixtures())
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
- assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
if err != nil {
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
diff --git a/integrations/lfs_getobject_test.go b/integrations/lfs_getobject_test.go
index 4b6bb140d3..14a8ac253e 100644
--- a/integrations/lfs_getobject_test.go
+++ b/integrations/lfs_getobject_test.go
@@ -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 {
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go
index 20a5c903a9..80093d66f1 100644
--- a/integrations/migration-test/migration_test.go
+++ b/integrations/migration-test/migration_test.go
@@ -82,8 +82,7 @@ func initMigrationTest(t *testing.T) func() {
}
}
- assert.NoError(t, git.InitOnceWithSync(context.Background()))
- git.CheckLFSVersion()
+ assert.NoError(t, git.InitFull(context.Background()))
setting.InitDBConfig()
setting.NewLogServices(true)
return deferFn