diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-05-07 15:36:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 07:36:48 +0000 |
commit | ebf0c969403d91ed80745ff5bd7dfbdb08174fc7 (patch) | |
tree | a9d0ab5c6f542258572fdda0b010351ea493169b /cmd | |
parent | 6ad77125cabe53a943d46b50e8cb79cfcea5491f (diff) | |
download | gitea-ebf0c969403d91ed80745ff5bd7dfbdb08174fc7.tar.gz gitea-ebf0c969403d91ed80745ff5bd7dfbdb08174fc7.zip |
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>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/hook.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/cmd/hook.go b/cmd/hook.go index 9c1cb66f2a..6e31710caf 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -338,6 +338,7 @@ Gitea or set your environment appropriately.`, "") isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki)) repoName := os.Getenv(repo_module.EnvRepoName) pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64) + prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64) pusherName := os.Getenv(repo_module.EnvPusherName) hookOptions := private.HookOptions{ @@ -347,6 +348,8 @@ Gitea or set your environment appropriately.`, "") GitObjectDirectory: os.Getenv(private.GitObjectDirectory), GitQuarantinePath: os.Getenv(private.GitQuarantinePath), GitPushOptions: pushOptions(), + PullRequestID: prID, + PushTrigger: repo_module.PushTrigger(os.Getenv(repo_module.EnvPushTrigger)), } oldCommitIDs := make([]string, hookBatchSize) newCommitIDs := make([]string, hookBatchSize) |