Skip to content

Commit f241201

Browse files
authored
Init git module before database migration (#21764) (#21766)
Backport #21764 Some database migrations depend on the git module.
1 parent 43bddc1 commit f241201

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

models/migrations/migrations.go

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"regexp"
1515
"strings"
1616

17+
"code.gitea.io/gitea/modules/git"
1718
"code.gitea.io/gitea/modules/log"
1819
"code.gitea.io/gitea/modules/setting"
1920

@@ -496,6 +497,13 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
496497
return nil
497498
}
498499

500+
// Some migration tasks depend on the git command
501+
if git.DefaultContext == nil {
502+
if err = git.InitSimple(context.Background()); err != nil {
503+
return err
504+
}
505+
}
506+
499507
// Migrate
500508
for i, m := range migrations[v-minDBVersion:] {
501509
log.Info("Migration[%d]: %s", v+int64(i), m.Description())

0 commit comments

Comments
 (0)