]> source.dussan.org Git - gitea.git/commit
Move database operations of merging a pull request to post receive hook and add a...
authorLunny Xiao <xiaolunwen@gmail.com>
Tue, 7 May 2024 07:36:48 +0000 (15:36 +0800)
committerGitHub <noreply@github.com>
Tue, 7 May 2024 07:36:48 +0000 (07:36 +0000)
commitebf0c969403d91ed80745ff5bd7dfbdb08174fc7
treea9d0ab5c6f542258572fdda0b010351ea493169b
parent6ad77125cabe53a943d46b50e8cb79cfcea5491f
Move database operations of merging a pull request to post receive hook and add a transaction (#30805)

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: 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