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:
parent
0fad40dd8c
commit
9899989ece
@ -301,11 +301,16 @@ func manuallyMerged(ctx context.Context, pr *issues_model.PullRequest) bool {
|
|||||||
pr.Merger = merger
|
pr.Merger = merger
|
||||||
pr.MergerID = merger.ID
|
pr.MergerID = merger.ID
|
||||||
|
|
||||||
if merged, err := pr.SetMerged(ctx); err != nil {
|
if err := db.WithTx(ctx, func(ctx context.Context) error {
|
||||||
|
if merged, err := pr.SetMerged(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
} else if !merged {
|
||||||
|
return errors.New("setMerged failed")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
log.Error("%-v setMerged : %v", pr, err)
|
log.Error("%-v setMerged : %v", pr, err)
|
||||||
return false
|
return false
|
||||||
} else if !merged {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_service.MergePullRequest(ctx, merger, pr)
|
notify_service.MergePullRequest(ctx, merger, pr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user