Skip to content

Commit 92525dd

Browse files
authored
Init git module before database migration (#21764)
Close #21761 Some database migrations depend on the git module.
1 parent 1d22911 commit 92525dd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

models/migrations/migrations.go

+9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package migrations
77

88
import (
9+
"context"
910
"fmt"
1011
"os"
1112

@@ -23,6 +24,7 @@ import (
2324
"code.gitea.io/gitea/models/migrations/v1_7"
2425
"code.gitea.io/gitea/models/migrations/v1_8"
2526
"code.gitea.io/gitea/models/migrations/v1_9"
27+
"code.gitea.io/gitea/modules/git"
2628
"code.gitea.io/gitea/modules/log"
2729
"code.gitea.io/gitea/modules/setting"
2830

@@ -527,6 +529,13 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
527529
return nil
528530
}
529531

532+
// Some migration tasks depend on the git command
533+
if git.DefaultContext == nil {
534+
if err = git.InitSimple(context.Background()); err != nil {
535+
return err
536+
}
537+
}
538+
530539
// Migrate
531540
for i, m := range migrations[v-minDBVersion:] {
532541
log.Info("Migration[%d]: %s", v+int64(i), m.Description())

0 commit comments

Comments
 (0)