Skip to content

Commit 3b3c58f

Browse files
committed
Fix git.Init for doctor sub-command
1 parent 3d7058a commit 3b3c58f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

cmd/doctor.go

-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"code.gitea.io/gitea/models/db"
1515
"code.gitea.io/gitea/models/migrations"
1616
"code.gitea.io/gitea/modules/doctor"
17-
"code.gitea.io/gitea/modules/git"
1817
"code.gitea.io/gitea/modules/log"
1918
"code.gitea.io/gitea/modules/setting"
2019

@@ -128,11 +127,6 @@ func runDoctor(ctx *cli.Context) error {
128127
stdCtx, cancel := installSignals()
129128
defer cancel()
130129

131-
// some doctor sub-commands need to use git command
132-
if err := git.InitFull(stdCtx); err != nil {
133-
return err
134-
}
135-
136130
// Silence the default loggers
137131
log.DelNamedLogger("console")
138132
log.DelNamedLogger(log.DEFAULT)

modules/doctor/doctor.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212

1313
"code.gitea.io/gitea/models/db"
14+
"code.gitea.io/gitea/modules/git"
1415
"code.gitea.io/gitea/modules/log"
1516
"code.gitea.io/gitea/modules/setting"
1617
)
@@ -49,7 +50,11 @@ func initDBDisableConsole(ctx context.Context, disableConsole bool) error {
4950

5051
setting.NewXORMLogService(disableConsole)
5152
if err := db.InitEngine(ctx); err != nil {
52-
return fmt.Errorf("models.SetEngine: %v", err)
53+
return fmt.Errorf("db.InitEngine: %w", err)
54+
}
55+
// some doctor sub-commands need to use git command
56+
if err := git.InitFull(ctx); err != nil {
57+
return fmt.Errorf("git.InitFull: %w", err)
5358
}
5459
return nil
5560
}

0 commit comments

Comments
 (0)