refactor: decouple context from migration structs#33399
Conversation
I think it depends on whether it really brings enough benefits. Golang itself (official packages, for example: |
|
According to the go's blog post the only reason why net/http has context in its struct is backwards compatibility: |
Yup, that's same to Gitea's code base. New code seldom stores context into a struct. Some old code already stores the context into the struct, which is not good, while not too bad if it hasn't caused any problem (for example: markup render also does so). That's what I meant "I think it depends on whether the refactoring really brings enough benefits." For "gogs downloader", the |
|
As a refactoring PR, I think we'd better to make it move on fast (to avoid unnecessary conflicts) If "gogs client ctx" is the last blocker, maybe I could help to try to figure out how to make it work (edit this PR) if you don't mind ....... |
|
Sorry for the delay, I started jumping between various topics semi-related (like what kind of magic makes gitea's context for request handlers) and unrelated (checking if migrating swagger to oapi-codegen is doable) to this. I figured that probably the best solution is to make the gogs library have context support so I went ahead and added it in my fork. |
Hmm, I prefer to keep using the official one (although it isn't active), in case the official one gets updated we might miss it. The forked dependencies are difficult to maintain TBH. I think the gogs client ctx could be fixed by #33399 (comment) |
|
The change isn't that big that a rebase once a while can't deal with. Though I see your point. |
|
-> Make gogs client work with context TheFox0x7#1 The reason why I don't want to introduce more forked packages:
ps: see the comment for another fork (just below): |
Make gogs client work with context
* giteaofficial/main: refactor: decouple context from migration structs (go-gitea#33399) Move gitgraph from modules to services layer (go-gitea#33527) Add go wrapper around git diff-tree --raw -r -M (go-gitea#33369) [skip ci] Updated translations via Crowdin Update MAINTAINERS (go-gitea#33529) Add cropping support when modifying the user/org/repo avatar (go-gitea#33498) [skip ci] Updated translations via Crowdin Add alphabetical project sorting (go-gitea#33504) Refactor gitdiff test (go-gitea#33507)
follow up to #33399 as I apparently missed this one.
I've started working on pulling out contexts from structs per golang conventions and I took migrations on first.
It should be fine apart from gogs which I have no idea how to decouple - safe for updating/forking gogs client.
Ideas and initial feedback are very much welcome.