Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Another round of db.DefaultContext refactor #27103

Merged
merged 22 commits into from Sep 25, 2023
Merged

Conversation

JakobDev
Copy link
Contributor

Part of #27065

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 16, 2023
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 16, 2023
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them topic/packages modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin labels Sep 16, 2023
services/cron/tasks_extended.go Outdated Show resolved Hide resolved
services/cron/tasks_extended.go Show resolved Hide resolved
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the mentioned comment has been fixed.

services/cron/cron.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Sep 16, 2023
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
@delvh delvh added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Sep 21, 2023
Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was even far more than I expected 😄

@delvh
Copy link
Member

delvh commented Sep 22, 2023

ping for reviewers

@delvh delvh added the backport/v1.21 This PR should be backported to Gitea 1.21 label Sep 22, 2023
func DeleteDeployKey(doer *user_model.User, id int64) error {
ctx, committer, err := db.TxContext(db.DefaultContext)
func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error {
dbCtx, committer, err := db.TxContext(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, but we may need a better mechanism for this. If ctx is already a transaction, TxContext will create a halfCommitter and the Commit on that does nothing. Only the commit of the outer transaction commits the inner queries. But the original code depends on a finished transaction because the following actions are not reversible.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 23, 2023
@delvh delvh added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 23, 2023
if err != nil {
return err
}
defer committer.Close()

if err := models.DeleteDeployKey(ctx, doer, id); err != nil {
if err := models.DeleteDeployKey(dbCtx, doer, id); err != nil {
return err
}
if err := committer.Commit(); err != nil {
return err
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add committer.Close() here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@lunny lunny enabled auto-merge (squash) September 25, 2023 13:11
@lunny lunny merged commit 7047df3 into go-gitea:main Sep 25, 2023
26 checks passed
@GiteaBot GiteaBot added this to the 1.22.0 milestone Sep 25, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 25, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Sep 25, 2023
Part of go-gitea#27065

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Sep 25, 2023
@JakobDev JakobDev deleted the nodefaultctx branch September 25, 2023 16:42
silverwind pushed a commit that referenced this pull request Sep 25, 2023
Backport #27103 by @JakobDev

Part of #27065

Co-authored-by: JakobDev <jakobdev@gmx.de>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 26, 2023
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Another round of `db.DefaultContext` refactor (go-gitea#27103)
  Fix more "locale" usages (go-gitea#27259)
  Always use `ctx.Locale.Tr` inside templates (go-gitea#27231)
  Disable `Test Delivery` and `Replay` webhook buttons when webhook is inactive (go-gitea#27211)

# Conflicts:
#	templates/base/footer_content.tmpl
#	templates/repo/issue/view_content/context_menu.tmpl
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. topic/packages type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants