From 75d96f4a0274c5b7566305d494c176e1a88b1589 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 9 Aug 2022 11:22:24 +0800 Subject: 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 Co-authored-by: Lunny Xiao --- cmd/doctor.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/doctor.go b/cmd/doctor.go index 3f16c6e2a6..1a15dd2941 100644 --- a/cmd/doctor.go +++ b/cmd/doctor.go @@ -14,6 +14,7 @@ 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" @@ -124,13 +125,18 @@ func runRecreateTable(ctx *cli.Context) error { } 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) - stdCtx, cancel := installSignals() - defer cancel() - // Now setup our own logFile := ctx.String("log-file") if !ctx.IsSet("log-file") { -- cgit v1.2.3