diff options
author | 6543 <6543@obermui.de> | 2022-05-04 18:06:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 18:06:23 +0200 |
commit | f034ee6cf0ab0806ef0b8edb5f38e6a5c37f2f7c (patch) | |
tree | 1aad4175bafd7907895c38c1e163220e2692f201 /services/pull/merge.go | |
parent | e933f314268e41477c85e44a255667c02b19f231 (diff) | |
download | gitea-f034ee6cf0ab0806ef0b8edb5f38e6a5c37f2f7c.tar.gz gitea-f034ee6cf0ab0806ef0b8edb5f38e6a5c37f2f7c.zip |
PullService lock via pullID (#19520)
* lock pull on git&db actions ...
* add TODO notes
* rename prQueue 2 prPatchCheckerQueue
* fmt
Diffstat (limited to 'services/pull/merge.go')
-rw-r--r-- | services/pull/merge.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/services/pull/merge.go b/services/pull/merge.go index ad93b9779f..fe295cbe03 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -34,7 +34,6 @@ import ( // Merge merges pull request to base repository. // Caller should check PR is ready to be merged (review and status checks) -// FIXME: add repoWorkingPull make sure two merges does not happen at same time. func Merge(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, mergeStyle repo_model.MergeStyle, expectedHeadCommitID, message string) error { if err := pr.LoadHeadRepo(); err != nil { log.Error("LoadHeadRepo: %v", err) @@ -44,6 +43,9 @@ func Merge(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repos return fmt.Errorf("LoadBaseRepo: %v", err) } + pullWorkingPool.CheckIn(fmt.Sprint(pr.ID)) + defer pullWorkingPool.CheckOut(fmt.Sprint(pr.ID)) + prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests) if err != nil { log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err) @@ -726,6 +728,9 @@ func CheckPullBranchProtections(ctx context.Context, pr *models.PullRequest, ski // MergedManually mark pr as merged manually func MergedManually(pr *models.PullRequest, doer *user_model.User, baseGitRepo *git.Repository, commitID string) error { + pullWorkingPool.CheckIn(fmt.Sprint(pr.ID)) + defer pullWorkingPool.CheckOut(fmt.Sprint(pr.ID)) + if err := db.WithTx(func(ctx context.Context) error { prUnit, err := pr.BaseRepo.GetUnitCtx(ctx, unit.TypePullRequests) if err != nil { |