Skip to content

Commit c8faf20

Browse files
committed
apply suggestion: guaranteeInit => mustInit
1 parent 9806f3a commit c8faf20

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

routers/init.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import (
4949
"gitea.com/go-chi/session"
5050
)
5151

52-
func guaranteeInit(fn func() error) {
52+
func mustInit(fn func() error) {
5353
err := fn()
5454
if err != nil {
5555
ptr := reflect.ValueOf(fn).Pointer()
@@ -58,7 +58,7 @@ func guaranteeInit(fn func() error) {
5858
}
5959
}
6060

61-
func guaranteeInitCtx(ctx context.Context, fn func(ctx context.Context) error) {
61+
func mustInitCtx(ctx context.Context, fn func(ctx context.Context) error) {
6262
err := fn(ctx)
6363
if err != nil {
6464
ptr := reflect.ValueOf(fn).Pointer()
@@ -70,8 +70,8 @@ func guaranteeInitCtx(ctx context.Context, fn func(ctx context.Context) error) {
7070
// InitGitServices init new services for git, this is also called in `contrib/pr/checkout.go`
7171
func InitGitServices() {
7272
setting.NewServices()
73-
guaranteeInit(storage.Init)
74-
guaranteeInit(repository.NewContext)
73+
mustInit(storage.Init)
74+
mustInit(repository.NewContext)
7575
}
7676

7777
func syncAppPathForGit(ctx context.Context) (err error) {
@@ -83,10 +83,10 @@ func syncAppPathForGit(ctx context.Context) (err error) {
8383
log.Info("AppPath changed from '%s' to '%s'", runtimeState.LastAppPath, setting.AppPath)
8484

8585
log.Info("re-sync repository hooks ...")
86-
guaranteeInitCtx(ctx, repo_module.SyncRepositoryHooks)
86+
mustInitCtx(ctx, repo_module.SyncRepositoryHooks)
8787

8888
log.Info("re-write ssh public keys ...")
89-
guaranteeInit(models.RewriteAllPublicKeys)
89+
mustInit(models.RewriteAllPublicKeys)
9090

9191
runtimeState.LastAppPath = setting.AppPath
9292
return setting.AppState.Set(runtimeState)
@@ -101,7 +101,7 @@ func GlobalInit(ctx context.Context) {
101101
log.Fatal("Gitea is not installed")
102102
}
103103

104-
guaranteeInitCtx(ctx, git.Init)
104+
mustInitCtx(ctx, git.Init)
105105
log.Info(git.VersionInfo())
106106

107107
git.CheckLFSVersion()
@@ -117,9 +117,9 @@ func GlobalInit(ctx context.Context) {
117117

118118
InitGitServices()
119119
mailer.NewContext()
120-
guaranteeInit(cache.NewContext)
120+
mustInit(cache.NewContext)
121121
notification.NewContext()
122-
guaranteeInit(archiver.Init)
122+
mustInit(archiver.Init)
123123

124124
highlight.NewContext()
125125
external.RegisterRenderers()
@@ -131,27 +131,27 @@ func GlobalInit(ctx context.Context) {
131131
log.Fatal("SQLite3 is set in settings but NOT Supported")
132132
}
133133

134-
guaranteeInitCtx(ctx, common.InitDBEngine)
134+
mustInitCtx(ctx, common.InitDBEngine)
135135
log.Info("ORM engine initialization successful!")
136136

137-
guaranteeInit(oauth2.Init)
137+
mustInit(oauth2.Init)
138138

139139
models.NewRepoContext()
140140

141141
// Booting long running goroutines.
142142
cron.NewContext()
143143
issue_indexer.InitIssueIndexer(false)
144144
code_indexer.Init()
145-
guaranteeInit(stats_indexer.Init)
145+
mustInit(stats_indexer.Init)
146146

147147
mirror_service.InitSyncMirrors()
148148
webhook.InitDeliverHooks()
149-
guaranteeInit(pull_service.Init)
150-
guaranteeInit(task.Init)
151-
guaranteeInit(repo_migrations.Init)
149+
mustInit(pull_service.Init)
150+
mustInit(task.Init)
151+
mustInit(repo_migrations.Init)
152152
eventsource.GetManager().Init()
153153

154-
guaranteeInitCtx(ctx, syncAppPathForGit)
154+
mustInitCtx(ctx, syncAppPathForGit)
155155

156156
if setting.SSH.StartBuiltinServer {
157157
ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)

0 commit comments

Comments
 (0)