mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:57:52 +01:00
Backport #21619 . A patch to #17335. Just like AppPath, Gitea writes its own CustomConf into git hook scripts too. If Gitea's CustomConf changes, then the git push may fail. Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
5bc3fbd511
commit
7a2daae7c3
@ -6,7 +6,8 @@ package appstate
|
|||||||
|
|
||||||
// RuntimeState contains app state for runtime, and we can save remote version for update checker here in future
|
// RuntimeState contains app state for runtime, and we can save remote version for update checker here in future
|
||||||
type RuntimeState struct {
|
type RuntimeState struct {
|
||||||
LastAppPath string `json:"last_app_path"`
|
LastAppPath string `json:"last_app_path"`
|
||||||
|
LastCustomConf string `json:"last_custom_conf"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the item name
|
// Name returns the item name
|
||||||
|
@ -74,21 +74,31 @@ func InitGitServices() {
|
|||||||
mustInit(repo_service.Init)
|
mustInit(repo_service.Init)
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncAppPathForGit(ctx context.Context) error {
|
func syncAppConfForGit(ctx context.Context) error {
|
||||||
runtimeState := new(appstate.RuntimeState)
|
runtimeState := new(appstate.RuntimeState)
|
||||||
if err := appstate.AppState.Get(runtimeState); err != nil {
|
if err := appstate.AppState.Get(runtimeState); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updated := false
|
||||||
if runtimeState.LastAppPath != setting.AppPath {
|
if runtimeState.LastAppPath != setting.AppPath {
|
||||||
log.Info("AppPath changed from '%s' to '%s'", runtimeState.LastAppPath, setting.AppPath)
|
log.Info("AppPath changed from '%s' to '%s'", runtimeState.LastAppPath, setting.AppPath)
|
||||||
|
runtimeState.LastAppPath = setting.AppPath
|
||||||
|
updated = true
|
||||||
|
}
|
||||||
|
if runtimeState.LastCustomConf != setting.CustomConf {
|
||||||
|
log.Info("CustomConf changed from '%s' to '%s'", runtimeState.LastCustomConf, setting.CustomConf)
|
||||||
|
runtimeState.LastCustomConf = setting.CustomConf
|
||||||
|
updated = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if updated {
|
||||||
log.Info("re-sync repository hooks ...")
|
log.Info("re-sync repository hooks ...")
|
||||||
mustInitCtx(ctx, repo_service.SyncRepositoryHooks)
|
mustInitCtx(ctx, repo_service.SyncRepositoryHooks)
|
||||||
|
|
||||||
log.Info("re-write ssh public keys ...")
|
log.Info("re-write ssh public keys ...")
|
||||||
mustInit(asymkey_model.RewriteAllPublicKeys)
|
mustInit(asymkey_model.RewriteAllPublicKeys)
|
||||||
|
|
||||||
runtimeState.LastAppPath = setting.AppPath
|
|
||||||
return appstate.AppState.Set(runtimeState)
|
return appstate.AppState.Set(runtimeState)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -153,7 +163,7 @@ func GlobalInitInstalled(ctx context.Context) {
|
|||||||
mustInit(repo_migrations.Init)
|
mustInit(repo_migrations.Init)
|
||||||
eventsource.GetManager().Init()
|
eventsource.GetManager().Init()
|
||||||
|
|
||||||
mustInitCtx(ctx, syncAppPathForGit)
|
mustInitCtx(ctx, syncAppConfForGit)
|
||||||
|
|
||||||
mustInit(ssh.Init)
|
mustInit(ssh.Init)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user