diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-08-09 11:22:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-09 11:22:24 +0800 |
commit | 75d96f4a0274c5b7566305d494c176e1a88b1589 (patch) | |
tree | d4dc134d9fea8f0f89f895e7bf30ec39146edf32 /cmd | |
parent | 820031e556af9548aa07e4de2669ca52bd7f63cb (diff) | |
download | gitea-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 'cmd')
-rw-r--r-- | cmd/doctor.go | 12 |
1 files changed, 9 insertions, 3 deletions
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") { |