]> source.dussan.org Git - gitea.git/commit
Sync gitea app path for git hooks and authorized keys when starting (#17335)
authorwxiaoguang <wxiaoguang@gmail.com>
Thu, 21 Oct 2021 09:22:43 +0000 (17:22 +0800)
committerGitHub <noreply@github.com>
Thu, 21 Oct 2021 09:22:43 +0000 (17:22 +0800)
commit83df0caf15c4a8c3b9336987f329501507c6d527
tree34fa87145972771c6d3ea417bba79028e3186b70
parent053b2f4dce2c404bcd7cb828147deb4b99ab71e6
Sync gitea app path for git hooks and authorized keys when starting (#17335)

Gitea writes its own AppPath into git hook scripts. If Gitea's AppPath changes, then the git push will fail.

This PR:

* Introduce an AppState module, it can persist app states into database
* During GlobalInit, Gitea will check if the current AppPath is the same as last one. If they don't match, Gitea will sync git hooks.
* Refactor some code to make them more clear.
* Also, "Detect if gitea binary's name changed" #11341 is related, we call models.RewriteAllPublicKeys to update ssh authorized_keys file
contrib/pr/checkout.go
models/appstate/appstate.go [new file with mode: 0644]
models/migrations/migrations.go
models/migrations/v200.go [new file with mode: 0644]
modules/appstate/appstate.go [new file with mode: 0644]
modules/appstate/appstate_test.go [new file with mode: 0644]
modules/appstate/db.go [new file with mode: 0644]
modules/appstate/item_runtime.go [new file with mode: 0644]
modules/repository/hooks.go
modules/setting/setting.go
routers/init.go