From 11dc6df5be5ae1da8d570e440f97060d2284dd13 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 14 Aug 2022 00:33:18 +0800 Subject: [PATCH] Fix git.Init for doctor sub-command (#20782) --- cmd/doctor.go | 6 ------ modules/doctor/doctor.go | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/doctor.go b/cmd/doctor.go index 1a15dd294..67a4ecc9c 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -14,7 +14,6 @@ import ( "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/migrations" "code.gitea.io/gitea/modules/doctor" - "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -128,11 +127,6 @@ func runDoctor(ctx *cli.Context) error { stdCtx, cancel := installSignals() defer cancel() - // some doctor sub-commands need to use git command - if err := git.InitFull(stdCtx); err != nil { - return err - } - // Silence the default loggers log.DelNamedLogger("console") log.DelNamedLogger(log.DEFAULT) diff --git a/modules/doctor/doctor.go b/modules/doctor/doctor.go index c8975a788..5d14cef55 100644 --- a/modules/doctor/doctor.go +++ b/modules/doctor/doctor.go @@ -11,6 +11,7 @@ import ( "strings" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" ) @@ -49,7 +50,11 @@ func initDBDisableConsole(ctx context.Context, disableConsole bool) error { setting.NewXORMLogService(disableConsole) if err := db.InitEngine(ctx); err != nil { - return fmt.Errorf("models.SetEngine: %v", err) + return fmt.Errorf("db.InitEngine: %w", err) + } + // some doctor sub-commands need to use git command + if err := git.InitFull(ctx); err != nil { + return fmt.Errorf("git.InitFull: %w", err) } return nil }