0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-25 18:54:37 +01:00
gitea/services
Lunny Xiao 34283a74e8
Allow detect whether it's in a database transaction for a context.Context (#21756)
Fix #19513

This PR introduce a new db method `InTransaction(context.Context)`,
and also builtin check on `db.TxContext` and `db.WithTx`.
There is also a new method `db.AutoTx` has been introduced but could be used by other PRs.

`WithTx` will always open a new transaction, if a transaction exist in context, return an error.
`AutoTx` will try to open a new transaction if no transaction exist in context.
That means it will always enter a transaction if there is no error.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2022-11-12 21:18:50 +01:00
..
agit Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
asymkey Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
attachment Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
auth Revert unrelated changes for SMTP auth (#21767) 2022-11-10 16:12:23 -05:00
automerge Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
comments Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
context
cron Refactor git command arguments and make all arguments to be safe to be used (#21535) 2022-10-23 22:44:45 +08:00
externalaccount
forms Revert unrelated changes for SMTP auth (#21767) 2022-11-10 16:12:23 -05:00
gitdiff Refactor git command arguments and make all arguments to be safe to be used (#21535) 2022-10-23 22:44:45 +08:00
issue Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
lfs
mailer feat: notify doers of a merge when automerging (#21553) 2022-11-03 23:49:00 +08:00
markup
migrations Handle branch name with prefix in GitHub migration (#20357) 2022-11-03 10:32:52 +08:00
mirror Refactor git command arguments and make all arguments to be safe to be used (#21535) 2022-10-23 22:44:45 +08:00
org Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
packages Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
pull Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
release Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
repository Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
task Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00
user Allow detect whether it's in a database transaction for a context.Context (#21756) 2022-11-12 21:18:50 +01:00
webhook Add Webhook authorization header (#20926) 2022-11-03 20:23:20 +02:00
wiki Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2022-10-24 20:29:17 +01:00