Monorepo for Tangled tangled.org

types: restore mispelled json field for backwards compat

both spellings are supported.

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 33a254d2 f150fdef

verified
Changed files
+21
types
+21
types/repo.go
··· 1 package types 2 3 import ( 4 "github.com/bluekeyes/go-gitdiff/gitdiff" 5 "github.com/go-git/go-git/v5/plumbing/object" 6 ) ··· 67 Reference `json:"reference"` 68 Commit *object.Commit `json:"commit,omitempty"` 69 IsDefault bool `json:"is_default,omitempty"` 70 } 71 72 type RepoTagsResponse struct {
··· 1 package types 2 3 import ( 4 + "encoding/json" 5 + 6 "github.com/bluekeyes/go-gitdiff/gitdiff" 7 "github.com/go-git/go-git/v5/plumbing/object" 8 ) ··· 69 Reference `json:"reference"` 70 Commit *object.Commit `json:"commit,omitempty"` 71 IsDefault bool `json:"is_default,omitempty"` 72 + } 73 + 74 + func (b *Branch) UnmarshalJSON(data []byte) error { 75 + aux := &struct { 76 + Reference `json:"reference"` 77 + Commit *object.Commit `json:"commit,omitempty"` 78 + IsDefault bool `json:"is_default,omitempty"` 79 + MispelledIsDefault bool `json:"is_deafult,omitempty"` // mispelled name 80 + }{} 81 + 82 + if err := json.Unmarshal(data, aux); err != nil { 83 + return err 84 + } 85 + 86 + b.Reference = aux.Reference 87 + b.Commit = aux.Commit 88 + b.IsDefault = aux.IsDefault || aux.MispelledIsDefault // whichever was set 89 + 90 + return nil 91 } 92 93 type RepoTagsResponse struct {