From 7f76169ad5d2d9066449f5446c79c90958d50887 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 10 Nov 2022 20:08:37 +0800 Subject: [PATCH] fix --- models/migrations/migrations.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 5f5ec8fdd7136..6ef4ef561794a 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -6,6 +6,7 @@ package migrations import ( + "context" "fmt" "os" @@ -23,6 +24,7 @@ import ( "code.gitea.io/gitea/models/migrations/v1_7" "code.gitea.io/gitea/models/migrations/v1_8" "code.gitea.io/gitea/models/migrations/v1_9" + "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" @@ -527,6 +529,13 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t return nil } + // Some migration tasks depend on the git command + if git.DefaultContext == nil { + if err = git.InitSimple(context.Background()); err != nil { + return err + } + } + // Migrate for i, m := range migrations[v-minDBVersion:] { log.Info("Migration[%d]: %s", v+int64(i), m.Description())