Skip to content

Commit d03cd54

Browse files
committed
Merge remote-tracking branch 'giteaofficial/release/v1.17'
* giteaofficial/release/v1.17: (35 commits) Simplify and fix migration 216 (go-gitea#20036) Alter hook_task TEXT fields to LONGTEXT (go-gitea#20038) (go-gitea#20041) Backtick table name in generic orphan check (go-gitea#20019) (go-gitea#20037) Respond with a 401 on git push when password isn't changed yet (go-gitea#20027) Fix delete pull head ref for DeleteIssue (go-gitea#20032) (go-gitea#20034) use quoted regexp instead of git fixed-value (go-gitea#20030) Dump should only copy regular files and symlink regular files (go-gitea#20015) (go-gitea#20021) Return 404 when tag is broken (go-gitea#20024) [skip ci] Updated translations via Crowdin [skip ci] Updated translations via Crowdin Add fgprof pprof profiler (go-gitea#20005) [skip ci] Updated translations via Crowdin Improve action table indices (go-gitea#19472) Add dbconsistency checks for Stopwatches (go-gitea#20010) fix push mirrors URL are no longer displayed on the UI (go-gitea#20011) Empty log queue on flush and close (go-gitea#19994) [skip ci] Updated translations via Crowdin Stop spurious APIFormat stopwatches logs (go-gitea#20008) Fix CountOrphanedLabels in orphan check (go-gitea#20009) Write Commit-Graphs in RepositoryDumper (go-gitea#20004) ...
2 parents bec4d38 + 2dc6571 commit d03cd54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1213
-431
lines changed

cmd/doctor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func runDoctor(ctx *cli.Context) error {
203203

204204
// Now we can set up our own logger to return information about what the doctor is doing
205205
if err := log.NewNamedLogger("doctorouter",
206-
1000,
206+
0,
207207
"console",
208208
"console",
209209
fmt.Sprintf(`{"level":"INFO","stacktracelevel":"NONE","colorize":%t,"flags":-1}`, colorize)); err != nil {

cmd/dump.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"code.gitea.io/gitea/modules/util"
2323

2424
"gitea.com/go-chi/session"
25-
archiver "github.com/mholt/archiver/v3"
25+
"github.com/mholt/archiver/v3"
2626
"github.com/urfave/cli"
2727
)
2828

@@ -439,8 +439,23 @@ func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeA
439439
}
440440
}
441441
} else {
442-
if err = addFile(w, currentInsidePath, currentAbsPath, verbose); err != nil {
443-
return err
442+
// only copy regular files and symlink regular files, skip non-regular files like socket/pipe/...
443+
shouldAdd := file.Mode().IsRegular()
444+
if !shouldAdd && file.Mode()&os.ModeSymlink == os.ModeSymlink {
445+
target, err := filepath.EvalSymlinks(currentAbsPath)
446+
if err != nil {
447+
return err
448+
}
449+
targetStat, err := os.Stat(target)
450+
if err != nil {
451+
return err
452+
}
453+
shouldAdd = targetStat.Mode().IsRegular()
454+
}
455+
if shouldAdd {
456+
if err = addFile(w, currentInsidePath, currentAbsPath, verbose); err != nil {
457+
return err
458+
}
444459
}
445460
}
446461
}

cmd/hook.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ func runHookPostReceive(c *cli.Context) error {
308308
ctx, cancel := installSignals()
309309
defer cancel()
310310

311+
setup("hooks/post-receive.log", c.Bool("debug"))
312+
311313
// First of all run update-server-info no matter what
312314
if _, _, err := git.NewCommand(ctx, "update-server-info").RunStdString(nil); err != nil {
313315
return fmt.Errorf("Failed to call 'git update-server-info': %v", err)
@@ -318,8 +320,6 @@ func runHookPostReceive(c *cli.Context) error {
318320
return nil
319321
}
320322

321-
setup("hooks/post-receive.log", c.Bool("debug"))
322-
323323
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
324324
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
325325
return fail(`Rejecting changes as Gitea environment not set.

cmd/web.go

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/routers"
2222
"code.gitea.io/gitea/routers/install"
2323

24+
"github.com/felixge/fgprof"
2425
"github.com/urfave/cli"
2526
ini "gopkg.in/ini.v1"
2627
)
@@ -145,6 +146,7 @@ func runWeb(ctx *cli.Context) error {
145146

146147
if setting.EnablePprof {
147148
go func() {
149+
http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler())
148150
_, _, finished := process.GetManager().AddTypedContext(context.Background(), "Web: PProf Server", process.SystemProcessType, true)
149151
log.Info("Starting pprof server on localhost:6060")
150152
log.Info("%v", http.ListenAndServe("localhost:6060", nil))

docs/content/doc/advanced/signing.en-us.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ The first option to discuss is the `SIGNING_KEY`. There are three main
8383
options:
8484

8585
- `none` - this prevents Gitea from signing any commits
86-
- `default` - Gitea will default to the key configured within
87-
`git config`
86+
- `default` - Gitea will default to the key configured within `git config`
8887
- `KEYID` - Gitea will sign commits with the gpg key with the ID
8988
`KEYID`. In this case you should provide a `SIGNING_NAME` and
9089
`SIGNING_EMAIL` to be displayed for this key.
@@ -98,6 +97,12 @@ repositories, `SIGNING_KEY=default` could be used to provide different
9897
signing keys on a per-repository basis. However, this is clearly not an
9998
ideal UI and therefore subject to change.
10099

100+
**Since 1.17**, Gitea runs git in its own home directory `[repository].ROOT` and uses its own config `{[repository].ROOT}/.gitconfig`.
101+
If you have your own customized git config for Gitea, you should set these configs in system git config (aka `/etc/gitconfig`)
102+
or the Gitea internal git config `{[repository].ROOT}/.gitconfig`.
103+
Related home files for git command (like `.gnupg`) should also be put in Gitea's git home directory `[repository].ROOT`.
104+
105+
101106
### `INITIAL_COMMIT`
102107

103108
This option determines whether Gitea should sign the initial commit
@@ -118,7 +123,7 @@ The possible values are:
118123

119124
- `never`: Never sign
120125
- `pubkey`: Only sign if the user has a public key
121-
- `twofa`: Only sign if the user logs in with two factor authentication
126+
- `twofa`: Only sign if the user logs in with two-factor authentication
122127
- `parentsigned`: Only sign if the parent commit is signed.
123128
- `always`: Always sign
124129

@@ -132,7 +137,7 @@ editor or API CRUD actions. The possible values are:
132137

133138
- `never`: Never sign
134139
- `pubkey`: Only sign if the user has a public key
135-
- `twofa`: Only sign if the user logs in with two factor authentication
140+
- `twofa`: Only sign if the user logs in with two-factor authentication
136141
- `parentsigned`: Only sign if the parent commit is signed.
137142
- `always`: Always sign
138143

@@ -146,7 +151,7 @@ The possible options are:
146151

147152
- `never`: Never sign
148153
- `pubkey`: Only sign if the user has a public key
149-
- `twofa`: Only sign if the user logs in with two factor authentication
154+
- `twofa`: Only sign if the user logs in with two-factor authentication
150155
- `basesigned`: Only sign if the parent commit in the base repo is signed.
151156
- `headsigned`: Only sign if the head commit in the head branch is signed.
152157
- `commitssigned`: Only sign if all the commits in the head branch to the merge point are signed.

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626
github.com/editorconfig/editorconfig-core-go/v2 v2.4.4
2727
github.com/emirpasic/gods v1.18.1
2828
github.com/ethantkoenig/rupture v1.0.1
29+
github.com/felixge/fgprof v0.9.2
2930
github.com/gliderlabs/ssh v0.3.4
3031
github.com/go-chi/chi/v5 v5.0.7
3132
github.com/go-chi/cors v1.2.1

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
426426
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
427427
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
428428
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
429+
github.com/felixge/fgprof v0.9.2 h1:tAMHtWMyl6E0BimjVbFt7fieU6FpjttsZN7j0wT5blc=
430+
github.com/felixge/fgprof v0.9.2/go.mod h1:+VNi+ZXtHIQ6wIw6bUT8nXQRefQflWECoFyRealT5sg=
429431
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
430432
github.com/felixge/httpsnoop v1.0.2 h1:+nS9g82KMXccJ/wp0zyRW9ZBHFETmMGtkk+2CTTrW4o=
431433
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
@@ -769,6 +771,7 @@ github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLe
769771
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
770772
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
771773
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
774+
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
772775
github.com/google/pprof v0.0.0-20220509035851-59ca7ad80af3 h1:vFrXU7L2gqtlP/ZGijSpaDIc16ZQrZI4FAuYtpQTyQc=
773776
github.com/google/pprof v0.0.0-20220509035851-59ca7ad80af3/go.mod h1:Pt31oes+eGImORns3McJn8zHefuQl2rG8l6xQjGYB4U=
774777
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
@@ -892,6 +895,7 @@ github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7/go.mod h1:SK73t
892895
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
893896
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
894897
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
898+
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
895899
github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
896900
github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
897901
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=

integrations/integration_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ func initIntegrationTest() {
174174
setting.LoadForTest()
175175
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
176176
_ = util.RemoveAll(repo_module.LocalCopyPath())
177+
178+
if err := git.InitOnceWithSync(context.Background()); err != nil {
179+
log.Fatal("git.InitOnceWithSync: %v", err)
180+
}
177181
git.CheckLFSVersion()
182+
178183
setting.InitDBConfig()
179184
if err := storage.Init(); err != nil {
180185
fmt.Printf("Init storage failed: %v", err)
@@ -275,7 +280,7 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
275280
assert.NoError(t, unittest.LoadFixtures())
276281
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
277282
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
278-
assert.NoError(t, git.InitOnceWithSync(context.Background()))
283+
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
279284
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
280285
if err != nil {
281286
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
@@ -576,7 +581,7 @@ func resetFixtures(t *testing.T) {
576581
assert.NoError(t, unittest.LoadFixtures())
577582
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
578583
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
579-
assert.NoError(t, git.InitOnceWithSync(context.Background()))
584+
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
580585
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
581586
if err != nil {
582587
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)

integrations/migration-test/migration_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func initMigrationTest(t *testing.T) func() {
6262
assert.True(t, len(setting.RepoRootPath) != 0)
6363
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
6464
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
65-
assert.NoError(t, git.InitOnceWithSync(context.Background()))
6665
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
6766
if err != nil {
6867
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)
@@ -83,6 +82,7 @@ func initMigrationTest(t *testing.T) func() {
8382
}
8483
}
8584

85+
assert.NoError(t, git.InitOnceWithSync(context.Background()))
8686
git.CheckLFSVersion()
8787
setting.InitDBConfig()
8888
setting.NewLogServices(true)

models/action.go

+19-7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"code.gitea.io/gitea/modules/util"
3131

3232
"xorm.io/builder"
33+
"xorm.io/xorm/schemas"
3334
)
3435

3536
// ActionType represents the type of an action.
@@ -70,25 +71,36 @@ const (
7071
// used in template render.
7172
type Action struct {
7273
ID int64 `xorm:"pk autoincr"`
73-
UserID int64 `xorm:"INDEX"` // Receiver user id.
74+
UserID int64 // Receiver user id.
7475
OpType ActionType
75-
ActUserID int64 `xorm:"INDEX"` // Action user id.
76-
ActUser *user_model.User `xorm:"-"`
77-
RepoID int64 `xorm:"INDEX"`
76+
ActUserID int64 // Action user id.
77+
ActUser *user_model.User `xorm:"-"`
78+
RepoID int64
7879
Repo *repo_model.Repository `xorm:"-"`
7980
CommentID int64 `xorm:"INDEX"`
8081
Comment *issues_model.Comment `xorm:"-"`
81-
IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"`
82+
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
8283
RefName string
83-
IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
84+
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
8485
Content string `xorm:"TEXT"`
85-
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
86+
CreatedUnix timeutil.TimeStamp `xorm:"created"`
8687
}
8788

8889
func init() {
8990
db.RegisterModel(new(Action))
9091
}
9192

93+
// TableIndices implements xorm's TableIndices interface
94+
func (a *Action) TableIndices() []*schemas.Index {
95+
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
96+
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
97+
98+
repoIndex := schemas.NewIndex("r_c_u_d", schemas.IndexType)
99+
repoIndex.AddColumn("repo_id", "created_unix", "user_id", "is_deleted")
100+
101+
return []*schemas.Index{actUserIndex, repoIndex}
102+
}
103+
92104
// GetOpType gets the ActionType of this action.
93105
func (a *Action) GetOpType() ActionType {
94106
return a.OpType

models/issues/label.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ func DeleteLabelsByRepoID(ctx context.Context, repoID int64) error {
733733

734734
// CountOrphanedLabels return count of labels witch are broken and not accessible via ui anymore
735735
func CountOrphanedLabels() (int64, error) {
736-
noref, err := db.GetEngine(db.DefaultContext).Table("label").Where("repo_id=? AND org_id=?", 0, 0).Count("label.id")
736+
noref, err := db.GetEngine(db.DefaultContext).Table("label").Where("repo_id=? AND org_id=?", 0, 0).Count()
737737
if err != nil {
738738
return 0, err
739739
}

models/migrations/migrations.go

+4
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ var migrations = []Migration{
387387
NewMigration("Add auto merge table", addAutoMergeTable),
388388
// v215 -> v216
389389
NewMigration("allow to view files in PRs", addReviewViewedFiles),
390+
// v216 -> v217
391+
NewMigration("Improve Action table indices", improveActionTableIndices),
392+
// v217 -> v218
393+
NewMigration("Alter hook_task table TEXT fields to LONGTEXT", alterHookTaskTextFieldsToLongText),
390394
}
391395

392396
// GetCurrentDBVersion returns the current db version

models/migrations/migrations_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func TestMain(m *testing.M) {
6666

6767
setting.SetCustomPathAndConf("", "", "")
6868
setting.LoadForTest()
69+
if err = git.InitOnceWithSync(context.Background()); err != nil {
70+
fmt.Printf("Unable to InitOnceWithSync: %v\n", err)
71+
os.Exit(1)
72+
}
6973
git.CheckLFSVersion()
7074
setting.InitDBConfig()
7175
setting.NewLogServices(true)
@@ -203,7 +207,7 @@ func prepareTestEnv(t *testing.T, skip int, syncModels ...interface{}) (*xorm.En
203207
deferFn := PrintCurrentTest(t, ourSkip)
204208
assert.NoError(t, os.RemoveAll(setting.RepoRootPath))
205209
assert.NoError(t, unittest.CopyDir(path.Join(filepath.Dir(setting.AppPath), "integrations/gitea-repositories-meta"), setting.RepoRootPath))
206-
assert.NoError(t, git.InitOnceWithSync(context.Background()))
210+
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
207211
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
208212
if err != nil {
209213
assert.NoError(t, err, "unable to read the new repo root: %v\n", err)

models/migrations/v216.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/modules/timeutil"
9+
10+
"xorm.io/xorm"
11+
"xorm.io/xorm/schemas"
12+
)
13+
14+
type improveActionTableIndicesAction struct {
15+
ID int64 `xorm:"pk autoincr"`
16+
UserID int64 // Receiver user id.
17+
OpType int
18+
ActUserID int64 // Action user id.
19+
RepoID int64
20+
CommentID int64 `xorm:"INDEX"`
21+
IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
22+
RefName string
23+
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
24+
Content string `xorm:"TEXT"`
25+
CreatedUnix timeutil.TimeStamp `xorm:"created"`
26+
}
27+
28+
// TableName sets the name of this table
29+
func (a *improveActionTableIndicesAction) TableName() string {
30+
return "action"
31+
}
32+
33+
// TableIndices implements xorm's TableIndices interface
34+
func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {
35+
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
36+
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
37+
38+
repoIndex := schemas.NewIndex("r_c_u_d", schemas.IndexType)
39+
repoIndex.AddColumn("repo_id", "created_unix", "user_id", "is_deleted")
40+
41+
return []*schemas.Index{actUserIndex, repoIndex}
42+
}
43+
44+
func improveActionTableIndices(x *xorm.Engine) error {
45+
return x.Sync2(&improveActionTableIndicesAction{})
46+
}

models/migrations/v217.go

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/modules/setting"
9+
10+
"xorm.io/xorm"
11+
)
12+
13+
func alterHookTaskTextFieldsToLongText(x *xorm.Engine) error {
14+
sess := x.NewSession()
15+
defer sess.Close()
16+
if err := sess.Begin(); err != nil {
17+
return err
18+
}
19+
20+
if setting.Database.UseMySQL {
21+
if _, err := sess.Exec("ALTER TABLE `hook_task` CHANGE `payload_content` `payload_content` LONGTEXT, CHANGE `request_content` `request_content` LONGTEXT, change `response_content` `response_content` LONGTEXT"); err != nil {
22+
return err
23+
}
24+
}
25+
return sess.Commit()
26+
}

models/unittest/testdb.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ func MainTest(m *testing.M, testOpts *TestOptions) {
117117
if err = CopyDir(filepath.Join(testOpts.GiteaRootPath, "integrations", "gitea-repositories-meta"), setting.RepoRootPath); err != nil {
118118
fatalTestError("util.CopyDir: %v\n", err)
119119
}
120+
120121
if err = git.InitOnceWithSync(context.Background()); err != nil {
121122
fatalTestError("git.Init: %v\n", err)
122123
}
124+
git.CheckLFSVersion()
123125

124126
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
125127
if err != nil {
@@ -202,7 +204,7 @@ func PrepareTestEnv(t testing.TB) {
202204
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
203205
metaPath := filepath.Join(giteaRoot, "integrations", "gitea-repositories-meta")
204206
assert.NoError(t, CopyDir(metaPath, setting.RepoRootPath))
205-
assert.NoError(t, git.InitOnceWithSync(context.Background()))
207+
assert.NoError(t, git.InitOnceWithSync(context.Background())) // the gitconfig has been removed above, so sync the gitconfig again
206208

207209
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
208210
assert.NoError(t, err)

0 commit comments

Comments
 (0)