diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 36312457..697af188 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -12416,7 +12416,7 @@ func (t *RepoPull) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 10 + fieldCount := 11 if t.Body == nil { fieldCount-- @@ -12613,6 +12613,32 @@ func (t *RepoPull) MarshalCBOR(w io.Writer) error { } } + // t.Versions ([]*tangled.RepoPull_Version) (slice) + if len("versions") > 1000000 { + return xerrors.Errorf("Value in field \"versions\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("versions"))); err != nil { + return err + } + if _, err := cw.WriteString(string("versions")); err != nil { + return err + } + + if len(t.Versions) > 8192 { + return xerrors.Errorf("Slice value in field t.Versions was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Versions))); err != nil { + return err + } + for _, v := range t.Versions { + if err := v.MarshalCBOR(cw); err != nil { + return err + } + + } + // t.CreatedAt (string) (string) if len("createdAt") > 1000000 { return xerrors.Errorf("Value in field \"createdAt\" was too long") @@ -12919,6 +12945,55 @@ func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { } } + // t.Versions ([]*tangled.RepoPull_Version) (slice) + case "versions": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.Versions: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.Versions = make([]*RepoPull_Version, 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.Versions[i] = new(RepoPull_Version) + if err := t.Versions[i].UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.Versions[i] pointer: %w", err) + } + } + + } + + } + } // t.CreatedAt (string) (string) case "createdAt": @@ -13987,6 +14062,198 @@ func (t *RepoPull_Target) UnmarshalCBOR(r io.Reader) (err error) { return nil } +func (t *RepoPull_Version) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + + cw := cbg.NewCborWriter(w) + fieldCount := 3 + + if t.Base == nil { + fieldCount-- + } + + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { + return err + } + + // t.Base (string) (string) + if t.Base != nil { + + if len("base") > 1000000 { + return xerrors.Errorf("Value in field \"base\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("base"))); err != nil { + return err + } + if _, err := cw.WriteString(string("base")); err != nil { + return err + } + + if t.Base == nil { + if _, err := cw.Write(cbg.CborNull); err != nil { + return err + } + } else { + if len(*t.Base) > 1000000 { + return xerrors.Errorf("Value in field t.Base was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Base))); err != nil { + return err + } + if _, err := cw.WriteString(string(*t.Base)); err != nil { + return err + } + } + } + + // t.Head (string) (string) + if len("head") > 1000000 { + return xerrors.Errorf("Value in field \"head\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("head"))); err != nil { + return err + } + if _, err := cw.WriteString(string("head")); err != nil { + return err + } + + if len(t.Head) > 1000000 { + return xerrors.Errorf("Value in field t.Head was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Head))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.Head)); err != nil { + return err + } + + // t.CreatedAt (string) (string) + if len("createdAt") > 1000000 { + return xerrors.Errorf("Value in field \"createdAt\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil { + return err + } + if _, err := cw.WriteString(string("createdAt")); err != nil { + return err + } + + if len(t.CreatedAt) > 1000000 { + return xerrors.Errorf("Value in field t.CreatedAt was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil { + return err + } + if _, err := cw.WriteString(string(t.CreatedAt)); err != nil { + return err + } + return nil +} + +func (t *RepoPull_Version) UnmarshalCBOR(r io.Reader) (err error) { + *t = RepoPull_Version{} + + 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("RepoPull_Version: map struct too large (%d)", extra) + } + + n := extra + + nameBuf := make([]byte, 9) + 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.Base (string) (string) + case "base": + + { + b, err := cr.ReadByte() + if err != nil { + return err + } + if b != cbg.CborNull[0] { + if err := cr.UnreadByte(); err != nil { + return err + } + + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Base = (*string)(&sval) + } + } + // t.Head (string) (string) + case "head": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.Head = string(sval) + } + // t.CreatedAt (string) (string) + case "createdAt": + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.CreatedAt = string(sval) + } + + 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 *Spindle) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) diff --git a/api/tangled/repopull.go b/api/tangled/repopull.go index 7e878f3a..60fd4ef3 100644 --- a/api/tangled/repopull.go +++ b/api/tangled/repopull.go @@ -17,21 +17,23 @@ func init() { } // // RECORDTYPE: RepoPull type RepoPull struct { - LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` - Body *string `json:"body,omitempty" cborgen:"body,omitempty"` - CreatedAt string `json:"createdAt" cborgen:"createdAt"` - DependentOn *string `json:"dependentOn,omitempty" cborgen:"dependentOn,omitempty"` - Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` - References []string `json:"references,omitempty" cborgen:"references,omitempty"` - Rounds []*RepoPull_Round `json:"rounds" cborgen:"rounds"` - Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"` - Target *RepoPull_Target `json:"target" cborgen:"target"` - Title string `json:"title" cborgen:"title"` + LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` + Body *string `json:"body,omitempty" cborgen:"body,omitempty"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + DependentOn *string `json:"dependentOn,omitempty" cborgen:"dependentOn,omitempty"` + Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"` + References []string `json:"references,omitempty" cborgen:"references,omitempty"` + // rounds: DEPRECATED: always empty + Rounds []*RepoPull_Round `json:"rounds" cborgen:"rounds"` + Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"` + Target *RepoPull_Target `json:"target" cborgen:"target"` + Title string `json:"title" cborgen:"title"` + Versions []*RepoPull_Version `json:"versions" cborgen:"versions"` } // RepoPull_Round is a "round" in the sh.tangled.repo.pull schema. // -// revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches. +// DEPRECATED: revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches. type RepoPull_Round struct { CreatedAt string `json:"createdAt" cborgen:"createdAt"` PatchBlob *util.LexBlob `json:"patchBlob" cborgen:"patchBlob"` @@ -48,3 +50,12 @@ type RepoPull_Target struct { Branch string `json:"branch" cborgen:"branch"` Repo string `json:"repo" cborgen:"repo"` } + +// RepoPull_Version is a "version" in the sh.tangled.repo.pull schema. +type RepoPull_Version struct { + // base: merge-base commit ID for combined interdiff + Base *string `json:"base,omitempty" cborgen:"base,omitempty"` + CreatedAt string `json:"createdAt" cborgen:"createdAt"` + // head: HEAD commit ID + Head string `json:"head" cborgen:"head"` +} diff --git a/cmd/cborgen/cborgen.go b/cmd/cborgen/cborgen.go index 36d45f61..e633bc6c 100644 --- a/cmd/cborgen/cborgen.go +++ b/cmd/cborgen/cborgen.go @@ -67,6 +67,7 @@ func main() { tangled.RepoPull_Source{}, tangled.RepoPullStatus{}, tangled.RepoPull_Target{}, + tangled.RepoPull_Version{}, tangled.Spindle{}, tangled.SpindleMember{}, tangled.String{}, diff --git a/lexicons/pulls/pull.json b/lexicons/pulls/pull.json index e4934808..70fd2dff 100644 --- a/lexicons/pulls/pull.json +++ b/lexicons/pulls/pull.json @@ -13,7 +13,8 @@ "target", "title", "createdAt", - "rounds" + "rounds", + "versions" ], "properties": { "title": { @@ -24,11 +25,19 @@ }, "rounds": { "type": "array", + "description": "DEPRECATED: always empty", "items": { "type": "ref", "ref": "#round" } }, + "versions": { + "type": "array", + "items": { + "type": "ref", + "ref": "#version" + } + }, "source": { "type": "ref", "ref": "#source" @@ -99,7 +108,7 @@ "patchBlob", "createdAt" ], - "description": "revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches.", + "description": "DEPRECATED: revisions of this pull request, newer rounds are appended to this array. appviews may reject records do not treat this field as append-only. the blob format is gzipped text-based git-format-patches.", "properties": { "createdAt": { "type": "string", @@ -112,6 +121,27 @@ ] } } + }, + "version": { + "type": "object", + "required": [ + "head", + "createdAt" + ], + "properties": { + "createdAt": { + "type": "string", + "format": "datetime" + }, + "base": { + "type": "string", + "description": "merge-base commit ID for combined interdiff" + }, + "head": { + "type": "string", + "description": "HEAD commit ID" + } + } } } }