Skip to content

Commit

Permalink
Init git module before database migration (#21764) (#21765)
Browse files Browse the repository at this point in the history
Backport #21764

Some database migrations depend on the git module.
  • Loading branch information
wxiaoguang authored Nov 10, 2022
1 parent b9dcf99 commit 87d05d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"regexp"
"strings"

"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"

Expand Down Expand Up @@ -513,6 +514,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())
Expand Down

0 comments on commit 87d05d3

Please sign in to comment.