]> source.dussan.org Git - gitea.git/commit
Move database operations of merging a pull request to post receive hook and add a...
authorGiteabot <teabot@gitea.io>
Wed, 8 May 2024 14:17:18 +0000 (22:17 +0800)
committerGitHub <noreply@github.com>
Wed, 8 May 2024 14:17:18 +0000 (14:17 +0000)
commitec3f5f9992d7ff8250c044a4467524d53bd50210
tree184279db35ee2ece7096a921dcdc74fdb2bd69e2
parentd4c2db39bf239d071c6ac96815efa8fd8b03ad94
Move database operations of merging a pull request to post receive hook and add a transaction (#30805) (#30888)

Backport #30805 by @lunny

Merging PR may fail because of various problems. The pull request may
have a dirty state because there is no transaction when merging a pull
request. ref
https://github.com/go-gitea/gitea/pull/25741#issuecomment-2074126393

This PR moves all database update operations to post-receive handler for
merging a pull request and having a database transaction. That means if
database operations fail, then the git merging will fail, the git client
will get a fail result.

There are already many tests for pull request merging, so we don't need
to add a new one.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
cmd/hook.go
modules/private/hook.go
modules/repository/env.go
routers/private/hook_post_receive.go
routers/private/hook_post_receive_test.go [new file with mode: 0644]
services/contexttest/context_tests.go
services/pull/merge.go
services/pull/update.go