-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
refactor some functions to support ctx as first parameter #21878
Conversation
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
@@ -44,7 +44,7 @@ func TransferOwnership(doer, newOwner *user_model.User, repo *repo_model.Reposit | |||
} | |||
repoWorkingPool.CheckOut(fmt.Sprint(repo.ID)) | |||
|
|||
newRepo, err := repo_model.GetRepositoryByID(repo.ID) | |||
newRepo, err := repo_model.GetRepositoryByID(db.DefaultContext, repo.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a function where I think a custom context is really needed:
From what I've seen so far, we need this especially for functions that update or delete something, right?
Let it simply be to define a transaction.
And if TransferOwnership
does not modify the database in a potentially destructive way, what does?
Also, there are currently at least 4 calls to the default context here…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or what kinds of functions need the context especially?
Because you seem to have it added mainly for GET
functions, and not for UPDATE/ DELETE
functions.
So, is there a guideline what should get a ctx parameter, or is it simply whatever we think needs it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or what kinds of functions need the context especially? Because you seem to have it added mainly for
GET
functions, and not forUPDATE/ DELETE
functions. So, is there a guideline what should get a ctx parameter, or is it simply whatever we think needs it?
This need a separate refactor PR, we need move some codes from models.TransferOwnership
to service layer TransferOwnership
.
Codecov Report
@@ Coverage Diff @@
## main #21878 +/- ##
=========================================
+ Coverage 0 48.14% +48.14%
=========================================
Files 0 1037 +1037
Lines 0 141393 +141393
=========================================
+ Hits 0 68073 +68073
- Misses 0 65180 +65180
- Partials 0 8140 +8140
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
* giteaofficial/main: docs: add `Edit this page` (go-gitea#21981) refactor some functions to support ctx as first parameter (go-gitea#21878) Remove deprecated packages & staticcheck fixes (go-gitea#22012) Add pnpm to packages/overview (go-gitea#22008) Update to Alpine 3.17 (go-gitea#21904) Update gitea-vet to check FSFE REUSE (go-gitea#22004) Multiple improvements for comment edit diff (go-gitea#21990) Remove session in api tests (go-gitea#21984) Remove duplicate "Actions" label in mobile view (go-gitea#21974) Fix generate index failure possibility on postgres (go-gitea#21998) Use path not filepath in template filenames (go-gitea#21993) Update chroma to v2.4.0 (go-gitea#22000) Util type to parse ref name (go-gitea#21969) Skip initing LFS storage if disabled (go-gitea#21996) Fix parallel creating commit status bug with tests (go-gitea#21911) Skip initing disabled storages (go-gitea#21985) Fix leaving organization bug on user settings -> orgs (go-gitea#21983) Fix typos (go-gitea#21979) Normalize `AppURL` according to RFC 3986 (go-gitea#21950)
No description provided.