diff options
author | Jason Song <i@wolfogre.com> | 2022-10-30 11:17:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-30 11:17:11 +0800 |
commit | e4a10f8c78963d8d36a735e53fca55c193c2cc2e (patch) | |
tree | 92a77ff364417ad20c2574030e981e069e4a88e9 /routers | |
parent | 6dba648e5d94084bc37a824fe9909529e1d8dafa (diff) | |
download | gitea-e4a10f8c78963d8d36a735e53fca55c193c2cc2e.tar.gz gitea-e4a10f8c78963d8d36a735e53fca55c193c2cc2e.zip |
Sync git hooks when config file path changed (#21619) (#21626)
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: zeripath <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/init.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/routers/init.go b/routers/init.go index 9045437f87..53b33f468f 100644 --- a/routers/init.go +++ b/routers/init.go @@ -76,21 +76,31 @@ func InitGitServices() { mustInit(repo_service.Init) } -func syncAppPathForGit(ctx context.Context) error { +func syncAppConfForGit(ctx context.Context) error { runtimeState := new(system.RuntimeState) if err := system.AppState.Get(runtimeState); err != nil { return err } + + updated := false if 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 ...") mustInitCtx(ctx, repo_service.SyncRepositoryHooks) log.Info("re-write ssh public keys ...") mustInit(asymkey_model.RewriteAllPublicKeys) - runtimeState.LastAppPath = setting.AppPath return system.AppState.Set(runtimeState) } return nil @@ -153,7 +163,7 @@ func GlobalInitInstalled(ctx context.Context) { mustInit(repo_migrations.Init) eventsource.GetManager().Init() - mustInitCtx(ctx, syncAppPathForGit) + mustInitCtx(ctx, syncAppConfForGit) mustInit(ssh.Init) |