1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-09 17:24:43 +00:00

Add missing transaction when set merge (#33113)

backport from #33079 

`SetMerged` should be in a database transaction otherwise it's possible
to have dirty data.
This commit is contained in:
Lunny Xiao 2025-01-06 10:21:14 -08:00 committed by GitHub
parent 0fad40dd8c
commit 9899989ece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -301,10 +301,15 @@ func manuallyMerged(ctx context.Context, pr *issues_model.PullRequest) bool {
pr.Merger = merger
pr.MergerID = merger.ID
if err := db.WithTx(ctx, func(ctx context.Context) error {
if merged, err := pr.SetMerged(ctx); err != nil {
log.Error("%-v setMerged : %v", pr, err)
return false
return err
} else if !merged {
return errors.New("setMerged failed")
}
return nil
}); err != nil {
log.Error("%-v setMerged : %v", pr, err)
return false
}