aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-11-10 22:22:39 +0800
committerGitHub <noreply@github.com>2022-11-10 14:22:39 +0000
commit92525ddffd8256a2cd9d10c55eca753073ffce8e (patch)
treecedcde1c2810175096434875efaa75aa9853410c /models
parent1d22911cfe08db93b4be5a99c2a67bcb132c7035 (diff)
downloadgitea-92525ddffd8256a2cd9d10c55eca753073ffce8e.tar.gz
gitea-92525ddffd8256a2cd9d10c55eca753073ffce8e.zip
Init git module before database migration (#21764)
Close #21761 Some database migrations depend on the git module.
Diffstat (limited to 'models')
-rw-r--r--models/migrations/migrations.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go
index 5f5ec8fdd7..6ef4ef5617 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())