lexicons: add lang breakdown to gitRefUpdate lexicon #314

merged
opened by oppi.li targeting master from push-snktzuwttuvu
Changed files
+386 -4
api
cmd
lexicons
+344 -2
api/tangled/cbor_gen.go
···
}
cw := cbg.NewCborWriter(w)
-
if _, err := cw.Write([]byte{162}); err != nil {
return err
}
···
if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil {
return err
}
return nil
}
···
n := extra
-
nameBuf := make([]byte, 12)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
default:
// Field doesn't exist on this type, so ignore it
···
return nil
}
func (t *GraphFollow) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
···
}
cw := cbg.NewCborWriter(w)
+
fieldCount := 3
+
if t.LangBreakdown == nil {
+
fieldCount--
+
}
+
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
return err
}
···
if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil {
return err
}
+
+
// t.LangBreakdown (tangled.GitRefUpdate_Meta_LangBreakdown) (struct)
+
if t.LangBreakdown != nil {
+
+
if len("langBreakdown") > 1000000 {
+
return xerrors.Errorf("Value in field \"langBreakdown\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("langBreakdown"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("langBreakdown")); err != nil {
+
return err
+
}
+
+
if err := t.LangBreakdown.MarshalCBOR(cw); err != nil {
+
return err
+
}
+
}
return nil
}
···
n := extra
+
nameBuf := make([]byte, 13)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
default:
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
}
+
// t.LangBreakdown (tangled.GitRefUpdate_Meta_LangBreakdown) (struct)
+
case "langBreakdown":
+
+
{
+
+
b, err := cr.ReadByte()
+
if err != nil {
+
return err
+
}
+
if b != cbg.CborNull[0] {
+
if err := cr.UnreadByte(); err != nil {
+
return err
+
}
+
t.LangBreakdown = new(GitRefUpdate_Meta_LangBreakdown)
+
if err := t.LangBreakdown.UnmarshalCBOR(cr); err != nil {
+
return xerrors.Errorf("unmarshaling t.LangBreakdown pointer: %w", err)
+
}
+
}
+
+
}
default:
// Field doesn't exist on this type, so ignore it
···
return nil
}
+
func (t *GitRefUpdate_Meta_LangBreakdown) MarshalCBOR(w io.Writer) error {
+
if t == nil {
+
_, err := w.Write(cbg.CborNull)
+
return err
+
}
+
+
cw := cbg.NewCborWriter(w)
+
fieldCount := 1
+
+
if t.Inputs == nil {
+
fieldCount--
+
}
+
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
+
return err
+
}
+
+
// t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice)
+
if t.Inputs != nil {
+
+
if len("inputs") > 1000000 {
+
return xerrors.Errorf("Value in field \"inputs\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("inputs")); err != nil {
+
return err
+
}
+
+
if len(t.Inputs) > 8192 {
+
return xerrors.Errorf("Slice value in field t.Inputs was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil {
+
return err
+
}
+
for _, v := range t.Inputs {
+
if err := v.MarshalCBOR(cw); err != nil {
+
return err
+
}
+
+
}
+
}
+
return nil
+
}
+
+
func (t *GitRefUpdate_Meta_LangBreakdown) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = GitRefUpdate_Meta_LangBreakdown{}
+
+
cr := cbg.NewCborReader(r)
+
+
maj, extra, err := cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
defer func() {
+
if err == io.EOF {
+
err = io.ErrUnexpectedEOF
+
}
+
}()
+
+
if maj != cbg.MajMap {
+
return fmt.Errorf("cbor input should be of type map")
+
}
+
+
if extra > cbg.MaxLength {
+
return fmt.Errorf("GitRefUpdate_Meta_LangBreakdown: map struct too large (%d)", extra)
+
}
+
+
n := extra
+
+
nameBuf := make([]byte, 6)
+
for i := uint64(0); i < n; i++ {
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
+
if err != nil {
+
return err
+
}
+
+
if !ok {
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
+
return err
+
}
+
continue
+
}
+
+
switch string(nameBuf[:nameLen]) {
+
// t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice)
+
case "inputs":
+
+
maj, extra, err = cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
+
if extra > 8192 {
+
return fmt.Errorf("t.Inputs: array too large (%d)", extra)
+
}
+
+
if maj != cbg.MajArray {
+
return fmt.Errorf("expected cbor array")
+
}
+
+
if extra > 0 {
+
t.Inputs = make([]*GitRefUpdate_Pair, extra)
+
}
+
+
for i := 0; i < int(extra); i++ {
+
{
+
var maj byte
+
var extra uint64
+
var err error
+
_ = maj
+
_ = extra
+
_ = err
+
+
{
+
+
b, err := cr.ReadByte()
+
if err != nil {
+
return err
+
}
+
if b != cbg.CborNull[0] {
+
if err := cr.UnreadByte(); err != nil {
+
return err
+
}
+
t.Inputs[i] = new(GitRefUpdate_Pair)
+
if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil {
+
return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err)
+
}
+
}
+
+
}
+
+
}
+
}
+
+
default:
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
+
return err
+
}
+
}
+
}
+
+
return nil
+
}
+
func (t *GitRefUpdate_Pair) MarshalCBOR(w io.Writer) error {
+
if t == nil {
+
_, err := w.Write(cbg.CborNull)
+
return err
+
}
+
+
cw := cbg.NewCborWriter(w)
+
+
if _, err := cw.Write([]byte{162}); err != nil {
+
return err
+
}
+
+
// t.Lang (string) (string)
+
if len("lang") > 1000000 {
+
return xerrors.Errorf("Value in field \"lang\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("lang"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("lang")); err != nil {
+
return err
+
}
+
+
if len(t.Lang) > 1000000 {
+
return xerrors.Errorf("Value in field t.Lang was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Lang))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.Lang)); err != nil {
+
return err
+
}
+
+
// t.Size (int64) (int64)
+
if len("size") > 1000000 {
+
return xerrors.Errorf("Value in field \"size\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("size"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("size")); err != nil {
+
return err
+
}
+
+
if t.Size >= 0 {
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
+
return err
+
}
+
} else {
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Size-1)); err != nil {
+
return err
+
}
+
}
+
+
return nil
+
}
+
+
func (t *GitRefUpdate_Pair) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = GitRefUpdate_Pair{}
+
+
cr := cbg.NewCborReader(r)
+
+
maj, extra, err := cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
defer func() {
+
if err == io.EOF {
+
err = io.ErrUnexpectedEOF
+
}
+
}()
+
+
if maj != cbg.MajMap {
+
return fmt.Errorf("cbor input should be of type map")
+
}
+
+
if extra > cbg.MaxLength {
+
return fmt.Errorf("GitRefUpdate_Pair: map struct too large (%d)", extra)
+
}
+
+
n := extra
+
+
nameBuf := make([]byte, 4)
+
for i := uint64(0); i < n; i++ {
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
+
if err != nil {
+
return err
+
}
+
+
if !ok {
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
+
return err
+
}
+
continue
+
}
+
+
switch string(nameBuf[:nameLen]) {
+
// t.Lang (string) (string)
+
case "lang":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.Lang = string(sval)
+
}
+
// t.Size (int64) (int64)
+
case "size":
+
{
+
maj, extra, err := cr.ReadHeader()
+
if err != nil {
+
return err
+
}
+
var extraI int64
+
switch maj {
+
case cbg.MajUnsignedInt:
+
extraI = int64(extra)
+
if extraI < 0 {
+
return fmt.Errorf("int64 positive overflow")
+
}
+
case cbg.MajNegativeInt:
+
extraI = int64(extra)
+
if extraI < 0 {
+
return fmt.Errorf("int64 negative overflow")
+
}
+
extraI = -1 - extraI
+
default:
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
+
}
+
+
t.Size = int64(extraI)
+
}
+
+
default:
+
// Field doesn't exist on this type, so ignore it
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
+
return err
+
}
+
}
+
}
+
+
return nil
+
}
func (t *GraphFollow) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
+13 -2
api/tangled/gitrefUpdate.go
···
}
type GitRefUpdate_Meta struct {
-
CommitCount *GitRefUpdate_Meta_CommitCount `json:"commitCount" cborgen:"commitCount"`
-
IsDefaultRef bool `json:"isDefaultRef" cborgen:"isDefaultRef"`
}
type GitRefUpdate_Meta_CommitCount struct {
···
Count int64 `json:"count" cborgen:"count"`
Email string `json:"email" cborgen:"email"`
}
···
}
type GitRefUpdate_Meta struct {
+
CommitCount *GitRefUpdate_Meta_CommitCount `json:"commitCount" cborgen:"commitCount"`
+
IsDefaultRef bool `json:"isDefaultRef" cborgen:"isDefaultRef"`
+
LangBreakdown *GitRefUpdate_Meta_LangBreakdown `json:"langBreakdown,omitempty" cborgen:"langBreakdown,omitempty"`
}
type GitRefUpdate_Meta_CommitCount struct {
···
Count int64 `json:"count" cborgen:"count"`
Email string `json:"email" cborgen:"email"`
}
+
+
type GitRefUpdate_Meta_LangBreakdown struct {
+
Inputs []*GitRefUpdate_Pair `json:"inputs,omitempty" cborgen:"inputs,omitempty"`
+
}
+
+
// GitRefUpdate_Pair is a "pair" in the sh.tangled.git.refUpdate schema.
+
type GitRefUpdate_Pair struct {
+
Lang string `json:"lang" cborgen:"lang"`
+
Size int64 `json:"size" cborgen:"size"`
+
}
+2
cmd/gen.go
···
tangled.GitRefUpdate_Meta{},
tangled.GitRefUpdate_Meta_CommitCount{},
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
tangled.GraphFollow{},
tangled.KnotMember{},
tangled.Pipeline{},
···
tangled.GitRefUpdate_Meta{},
tangled.GitRefUpdate_Meta_CommitCount{},
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
+
tangled.GitRefUpdate_Meta_LangBreakdown{},
+
tangled.GitRefUpdate_Pair{},
tangled.GraphFollow{},
tangled.KnotMember{},
tangled.Pipeline{},
+27
lexicons/git/refUpdate.json
···
"type": "boolean",
"default": "false"
},
"commitCount": {
"type": "object",
"required": [],
···
}
}
}
}
}
}
···
"type": "boolean",
"default": "false"
},
+
"langBreakdown": {
+
"type": "object",
+
"properties": {
+
"inputs": {
+
"type": "array",
+
"items": {
+
"type": "ref",
+
"ref": "#pair"
+
}
+
}
+
}
+
},
"commitCount": {
"type": "object",
"required": [],
···
}
}
}
+
},
+
"pair": {
+
"type": "object",
+
"required": [
+
"lang",
+
"size"
+
],
+
"properties": {
+
"lang": {
+
"type": "string"
+
},
+
"size": {
+
"type": "integer"
+
}
+
}
}
}
}