Skip to content

Commit bd3e99b

Browse files
wxiaoguangfsologureng
authored andcommitted
Init git module before database migration (go-gitea#21764)
Close go-gitea#21761 Some database migrations depend on the git module.
1 parent 8e02e15 commit bd3e99b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

models/migrations/migrations.go

Lines changed: 9 additions & 0 deletions
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)