Init git module before database migration (#21764) (#21765)

Backport #21764

Some database migrations depend on the git module.
tokarchuk/v1.18
wxiaoguang 2 years ago committed by GitHub
parent b9dcf991b9
commit 87d05d376d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      models/migrations/migrations.go

@ -14,6 +14,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
@ -513,6 +514,13 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
return nil 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 // Migrate
for i, m := range migrations[v-minDBVersion:] { for i, m := range migrations[v-minDBVersion:] {
log.Info("Migration[%d]: %s", v+int64(i), m.Description()) log.Info("Migration[%d]: %s", v+int64(i), m.Description())

Loading…
Cancel
Save