feat(repository_submodules): add ExtendedTrailers and deprecate ExtendedTrailerValues
What does this MR do?
Adds SubmoduleCommit.ExtendedTrailers, the name Commit.ExtendedTrailers has, and deprecates ExtendedTrailerValues in its favour, as asked in the review of !3082 and in this MR's review, so callers can move to the new field now instead of in v4.0.
A custom UnmarshalJSON fills both fields from the same extended_trailers key, the way AuditEventDetails decodes change. Two fields with the same JSON tag would both be ignored by encoding/json, so the tag stays on ExtendedTrailerValues and ExtendedTrailers is json:"-": encoding a SubmoduleCommit gives the same bytes as before. v4.0 can then remove ExtendedTrailerValues and UnmarshalJSON and move the tag to ExtendedTrailers, which the 4.0 issue tracks.
Is this a breaking change?
No. ExtendedTrailerValues decodes and encodes as before, and callers that read it get a staticcheck SA1019 warning pointing to ExtendedTrailers. As with any type that gains an UnmarshalJSON, a caller's own struct that embeds SubmoduleCommit would now decode through it; nothing in client-go embeds it.
How was this tested?
TestRepositorySubmodulesService_UpdateSubmodule_GitLabAnswerdecodes an answer GitLab EE 19.5.3 sent to this endpoint (testdata/update_submodule.json) into both fields. GitLab sendsextended_trailersthere as{}even when the commit message carries trailers, since the endpoint reads the commit without them, so the existing test keeps covering a trailer with two values.TestSubmoduleCommit_JSONRoundTripdecodes, encodes and decodes again: both fields keep their values, the encoded keys are the 18 from before, and a second encoding gives the same bytes.TestSubmoduleCommit_UnmarshalJSON_WrongTypechecks that a value of the wrong type still leaves both fields asExtendedTrailerValueswas left before.- Built against
mainand against this branch, a program that decodes and encodes tenSubmoduleCommitvalues withjson.Marshal,json.MarshalIndentand anEncoderwithout HTML escaping prints the same bytes and the sameExtendedTrailerValueson both, with Go 1.26.10 and 1.27.3. Only the text of the error for a value of the wrong type differs, not what is decoded around it. - A module outside the package gets one
SA1019for readingExtendedTrailerValuesand none for readingExtendedTrailers. make generateandmake fmtchange no file, andmake lint(golangci-lint 2.15.0, buf 1.55.1) andmake testpass on Go 1.27.3.make testalso passes on Go 1.26.10.
!3082 (merged) and !3085 (merged) came from maintaining gitlab-mcp-server, which is built on this library.