From 33a254d2102d3fd330fa0bc09d820fec9232b7ae Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Mon, 17 Nov 2025 04:11:25 +0000 Subject: [PATCH] types: restore mispelled json field for backwards compat Change-Id: xurkpxuzwzlorszosxvuyrxykypwrpux both spellings are supported. Signed-off-by: oppiliappan --- types/repo.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/types/repo.go b/types/repo.go index 3639f067..8e664959 100644 --- a/types/repo.go +++ b/types/repo.go @@ -1,6 +1,8 @@ package types import ( + "encoding/json" + "github.com/bluekeyes/go-gitdiff/gitdiff" "github.com/go-git/go-git/v5/plumbing/object" ) @@ -69,6 +71,25 @@ type Branch struct { IsDefault bool `json:"is_default,omitempty"` } +func (b *Branch) UnmarshalJSON(data []byte) error { + aux := &struct { + Reference `json:"reference"` + Commit *object.Commit `json:"commit,omitempty"` + IsDefault bool `json:"is_default,omitempty"` + MispelledIsDefault bool `json:"is_deafult,omitempty"` // mispelled name + }{} + + if err := json.Unmarshal(data, aux); err != nil { + return err + } + + b.Reference = aux.Reference + b.Commit = aux.Commit + b.IsDefault = aux.IsDefault || aux.MispelledIsDefault // whichever was set + + return nil +} + type RepoTagsResponse struct { Tags []*TagReference `json:"tags,omitempty"` } -- 2.43.0