feat(events): add Imported, ImportedFrom and WikiPage to both event structs
What does this MR do?
ContributionEvent and ProjectEvent both decode API::Entities::Event, and neither models three of the fields it exposes.
Read from gitlab-org/gitlab at commit e5d23f6d, the tip of master when this was written:
| Field | Exposed at | Sent |
|---|---|---|
wiki_page |
event.rb:17 | only when event.wiki_page?, rendered with Entities::WikiPageBasic |
imported |
event.rb:18 | always |
imported_from |
event.rb:19 | always, "none" for an event that was not imported |
EventWikiPage is the Go shape of API::Entities::WikiPageBasic: format, slug, title and wiki_page_meta_id. It is a pointer on both structs because the field is conditional, so nil distinguishes "not a wiki event" from a wiki page with empty strings, the same way ContributionEvent.Note and Package.Pipeline are already pointers for the same reason.
Both new fields go after Author, which is where the entity exposes them: note, author, wiki_page, imported, imported_from, push_data, author_username.
Two things I noticed while checking the entity and deliberately did not change, since removing an exported field is breaking and the fields are harmless as they stand. Title is on both structs and API::Entities::Event exposes no title at all, only target_title, so it has always decoded as the empty string. The test fixtures in this repository send "title": null for it, which is what kept that invisible. ProjectEvent.Data is in the same position: the entity exposes no data key. I am happy to send a follow-up that deprecates either, if that is wanted.
I found this while developing an MCP server on top of this library, https://github.com/jmrplens/gitlab-mcp-server, which currently reads all three keys out of the raw response beside the SDK decode.
Is this a breaking change?
No. Three additive fields on each of two response structs, plus one new exported type. Nothing is renamed, retyped, removed or moved.
ImportedFrom is worth one sentence for anyone comparing responses: GitLab sends the string "none" rather than an empty string for an event that was not imported, so a caller checking for "" will not get what they expect. That is GitLab's value, not a choice made here.
How was this tested?
TestUsersService_ListUserContributionEvents now sends imported and imported_from on its existing event and a second event that is a wiki page creation, asserting the decoded EventWikiPage and the imported_from: "none" case.
TestEventsService_ListProjectVisibleEvents gains the same wiki page event for ProjectEvent, and its two existing events keep no wiki_page key, so the nil case is asserted too.
go build ./..., go test . and golangci-lint run ./... all pass locally, and gofumpt -l reports nothing on the changed files.
Related to #2300