You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/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>
2 years ago
..
agit Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2 years ago
asymkey Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
attachment Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
auth Revert unrelated changes for SMTP auth (#21767) 2 years ago
automerge Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
comments Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
context Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
cron Refactor git command arguments and make all arguments to be safe to be used (#21535) 2 years ago
externalaccount Refactor auth package (#17962) 3 years ago
forms Revert unrelated changes for SMTP auth (#21767) 2 years ago
gitdiff Refactor git command arguments and make all arguments to be safe to be used (#21535) 2 years ago
issue Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
lfs Prevent Authorization header for presigned LFS urls (#21531) 2 years ago
mailer feat: notify doers of a merge when automerging (#21553) 2 years ago
markup Link mentioned user in markdown only if they are visible to viewer (#21554) 2 years ago
migrations Handle branch name with prefix in GitHub migration (#20357) 2 years ago
mirror Refactor git command arguments and make all arguments to be safe to be used (#21535) 2 years ago
org Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
packages Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
pull Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
release Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
repository Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
task Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2 years ago
user Allow detect whether it's in a database transaction for a context.Context (#21756) 2 years ago
webhook Add Webhook authorization header (#20926) 2 years ago
wiki Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551) 2 years ago