···3924392439253925 return nil
39263926}
39273927+func (t *PijulRefUpdate) MarshalCBOR(w io.Writer) error {
39283928+ if t == nil {
39293929+ _, err := w.Write(cbg.CborNull)
39303930+ return err
39313931+ }
39323932+39333933+ cw := cbg.NewCborWriter(w)
39343934+ fieldCount := 8
39353935+39363936+ if t.Languages == nil {
39373937+ fieldCount--
39383938+ }
39393939+39403940+ if t.OldState == nil {
39413941+ fieldCount--
39423942+ }
39433943+39443944+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
39453945+ return err
39463946+ }
39473947+39483948+ // t.Repo (string) (string)
39493949+ if len("repo") > 1000000 {
39503950+ return xerrors.Errorf("Value in field \"repo\" was too long")
39513951+ }
39523952+39533953+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
39543954+ return err
39553955+ }
39563956+ if _, err := cw.WriteString(string("repo")); err != nil {
39573957+ return err
39583958+ }
39593959+39603960+ if len(t.Repo) > 1000000 {
39613961+ return xerrors.Errorf("Value in field t.Repo was too long")
39623962+ }
39633963+39643964+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
39653965+ return err
39663966+ }
39673967+ if _, err := cw.WriteString(string(t.Repo)); err != nil {
39683968+ return err
39693969+ }
39703970+39713971+ // t.CommitterDid (string) (string)
39723972+ if len("committerDid") > 1000000 {
39733973+ return xerrors.Errorf("Value in field \"committerDid\" was too long")
39743974+ }
39753975+39763976+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("committerDid"))); err != nil {
39773977+ return err
39783978+ }
39793979+ if _, err := cw.WriteString(string("committerDid")); err != nil {
39803980+ return err
39813981+ }
39823982+39833983+ if len(t.CommitterDid) > 1000000 {
39843984+ return xerrors.Errorf("Value in field t.CommitterDid was too long")
39853985+ }
39863986+39873987+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CommitterDid))); err != nil {
39883988+ return err
39893989+ }
39903990+ if _, err := cw.WriteString(string(t.CommitterDid)); err != nil {
39913991+ return err
39923992+ }
39933993+39943994+ // t.LexiconTypeID (string) (string)
39953995+ if len("$type") > 1000000 {
39963996+ return xerrors.Errorf("Value in field \"$type\" was too long")
39973997+ }
39983998+39993999+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
40004000+ return err
40014001+ }
40024002+ if _, err := cw.WriteString(string("$type")); err != nil {
40034003+ return err
40044004+ }
40054005+40064006+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pijul.refUpdate"))); err != nil {
40074007+ return err
40084008+ }
40094009+ if _, err := cw.WriteString(string("sh.tangled.pijul.refUpdate")); err != nil {
40104010+ return err
40114011+ }
40124012+40134013+ // t.Changes ([]string) (slice)
40144014+ if len("changes") > 1000000 {
40154015+ return xerrors.Errorf("Value in field \"changes\" was too long")
40164016+ }
40174017+40184018+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("changes"))); err != nil {
40194019+ return err
40204020+ }
40214021+ if _, err := cw.WriteString(string("changes")); err != nil {
40224022+ return err
40234023+ }
40244024+40254025+ if len(t.Changes) > 8192 {
40264026+ return xerrors.Errorf("Slice value in field t.Changes was too long")
40274027+ }
40284028+40294029+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Changes))); err != nil {
40304030+ return err
40314031+ }
40324032+ for _, v := range t.Changes {
40334033+ if len(v) > 1000000 {
40344034+ return xerrors.Errorf("Value in field v was too long")
40354035+ }
40364036+40374037+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
40384038+ return err
40394039+ }
40404040+ if _, err := cw.WriteString(string(v)); err != nil {
40414041+ return err
40424042+ }
40434043+40444044+ }
40454045+40464046+ // t.Channel (string) (string)
40474047+ if len("channel") > 1000000 {
40484048+ return xerrors.Errorf("Value in field \"channel\" was too long")
40494049+ }
40504050+40514051+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("channel"))); err != nil {
40524052+ return err
40534053+ }
40544054+ if _, err := cw.WriteString(string("channel")); err != nil {
40554055+ return err
40564056+ }
40574057+40584058+ if len(t.Channel) > 1000000 {
40594059+ return xerrors.Errorf("Value in field t.Channel was too long")
40604060+ }
40614061+40624062+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Channel))); err != nil {
40634063+ return err
40644064+ }
40654065+ if _, err := cw.WriteString(string(t.Channel)); err != nil {
40664066+ return err
40674067+ }
40684068+40694069+ // t.NewState (string) (string)
40704070+ if len("newState") > 1000000 {
40714071+ return xerrors.Errorf("Value in field \"newState\" was too long")
40724072+ }
40734073+40744074+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newState"))); err != nil {
40754075+ return err
40764076+ }
40774077+ if _, err := cw.WriteString(string("newState")); err != nil {
40784078+ return err
40794079+ }
40804080+40814081+ if len(t.NewState) > 1000000 {
40824082+ return xerrors.Errorf("Value in field t.NewState was too long")
40834083+ }
40844084+40854085+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewState))); err != nil {
40864086+ return err
40874087+ }
40884088+ if _, err := cw.WriteString(string(t.NewState)); err != nil {
40894089+ return err
40904090+ }
40914091+40924092+ // t.OldState (string) (string)
40934093+ if t.OldState != nil {
40944094+40954095+ if len("oldState") > 1000000 {
40964096+ return xerrors.Errorf("Value in field \"oldState\" was too long")
40974097+ }
40984098+40994099+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldState"))); err != nil {
41004100+ return err
41014101+ }
41024102+ if _, err := cw.WriteString(string("oldState")); err != nil {
41034103+ return err
41044104+ }
41054105+41064106+ if t.OldState == nil {
41074107+ if _, err := cw.Write(cbg.CborNull); err != nil {
41084108+ return err
41094109+ }
41104110+ } else {
41114111+ if len(*t.OldState) > 1000000 {
41124112+ return xerrors.Errorf("Value in field t.OldState was too long")
41134113+ }
41144114+41154115+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OldState))); err != nil {
41164116+ return err
41174117+ }
41184118+ if _, err := cw.WriteString(string(*t.OldState)); err != nil {
41194119+ return err
41204120+ }
41214121+ }
41224122+ }
41234123+41244124+ // t.Languages (tangled.PijulRefUpdate_Languages) (struct)
41254125+ if t.Languages != nil {
41264126+41274127+ if len("languages") > 1000000 {
41284128+ return xerrors.Errorf("Value in field \"languages\" was too long")
41294129+ }
41304130+41314131+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("languages"))); err != nil {
41324132+ return err
41334133+ }
41344134+ if _, err := cw.WriteString(string("languages")); err != nil {
41354135+ return err
41364136+ }
41374137+41384138+ if err := t.Languages.MarshalCBOR(cw); err != nil {
41394139+ return err
41404140+ }
41414141+ }
41424142+ return nil
41434143+}
41444144+41454145+func (t *PijulRefUpdate) UnmarshalCBOR(r io.Reader) (err error) {
41464146+ *t = PijulRefUpdate{}
41474147+41484148+ cr := cbg.NewCborReader(r)
41494149+41504150+ maj, extra, err := cr.ReadHeader()
41514151+ if err != nil {
41524152+ return err
41534153+ }
41544154+ defer func() {
41554155+ if err == io.EOF {
41564156+ err = io.ErrUnexpectedEOF
41574157+ }
41584158+ }()
41594159+41604160+ if maj != cbg.MajMap {
41614161+ return fmt.Errorf("cbor input should be of type map")
41624162+ }
41634163+41644164+ if extra > cbg.MaxLength {
41654165+ return fmt.Errorf("PijulRefUpdate: map struct too large (%d)", extra)
41664166+ }
41674167+41684168+ n := extra
41694169+41704170+ nameBuf := make([]byte, 9)
41714171+ for i := uint64(0); i < n; i++ {
41724172+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
41734173+ if err != nil {
41744174+ return err
41754175+ }
41764176+41774177+ if !ok {
41784178+ // Field doesn't exist on this type, so ignore it
41794179+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
41804180+ return err
41814181+ }
41824182+ continue
41834183+ }
41844184+41854185+ switch string(nameBuf[:nameLen]) {
41864186+ // t.Repo (string) (string)
41874187+ case "repo":
41884188+41894189+ {
41904190+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
41914191+ if err != nil {
41924192+ return err
41934193+ }
41944194+41954195+ t.Repo = string(sval)
41964196+ }
41974197+ // t.LexiconTypeID (string) (string)
41984198+ case "$type":
41994199+42004200+ {
42014201+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42024202+ if err != nil {
42034203+ return err
42044204+ }
42054205+42064206+ t.LexiconTypeID = string(sval)
42074207+ }
42084208+ // t.Changes ([]string) (slice)
42094209+ case "changes":
42104210+42114211+ maj, extra, err = cr.ReadHeader()
42124212+ if err != nil {
42134213+ return err
42144214+ }
42154215+42164216+ if extra > 8192 {
42174217+ return fmt.Errorf("t.Changes: array too large (%d)", extra)
42184218+ }
42194219+42204220+ if maj != cbg.MajArray {
42214221+ return fmt.Errorf("expected cbor array")
42224222+ }
42234223+42244224+ if extra > 0 {
42254225+ t.Changes = make([]string, extra)
42264226+ }
42274227+42284228+ for i := 0; i < int(extra); i++ {
42294229+ {
42304230+ var maj byte
42314231+ var extra uint64
42324232+ var err error
42334233+ _ = maj
42344234+ _ = extra
42354235+ _ = err
42364236+42374237+ {
42384238+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42394239+ if err != nil {
42404240+ return err
42414241+ }
42424242+42434243+ t.Changes[i] = string(sval)
42444244+ }
42454245+42464246+ }
42474247+ }
42484248+ // t.Channel (string) (string)
42494249+ case "channel":
42504250+42514251+ {
42524252+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42534253+ if err != nil {
42544254+ return err
42554255+ }
42564256+42574257+ t.Channel = string(sval)
42584258+ }
42594259+ // t.CommitterDid (string) (string)
42604260+ case "committerDid":
42614261+42624262+ {
42634263+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42644264+ if err != nil {
42654265+ return err
42664266+ }
42674267+42684268+ t.CommitterDid = string(sval)
42694269+ }
42704270+ // t.NewState (string) (string)
42714271+ case "newState":
42724272+42734273+ {
42744274+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42754275+ if err != nil {
42764276+ return err
42774277+ }
42784278+42794279+ t.NewState = string(sval)
42804280+ }
42814281+ // t.OldState (string) (string)
42824282+ case "oldState":
42834283+42844284+ {
42854285+ b, err := cr.ReadByte()
42864286+ if err != nil {
42874287+ return err
42884288+ }
42894289+ if b != cbg.CborNull[0] {
42904290+ if err := cr.UnreadByte(); err != nil {
42914291+ return err
42924292+ }
42934293+42944294+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
42954295+ if err != nil {
42964296+ return err
42974297+ }
42984298+42994299+ t.OldState = (*string)(&sval)
43004300+ }
43014301+ }
43024302+ // t.Languages (tangled.PijulRefUpdate_Languages) (struct)
43034303+ case "languages":
43044304+43054305+ {
43064306+43074307+ b, err := cr.ReadByte()
43084308+ if err != nil {
43094309+ return err
43104310+ }
43114311+ if b != cbg.CborNull[0] {
43124312+ if err := cr.UnreadByte(); err != nil {
43134313+ return err
43144314+ }
43154315+ t.Languages = new(PijulRefUpdate_Languages)
43164316+ if err := t.Languages.UnmarshalCBOR(cr); err != nil {
43174317+ return xerrors.Errorf("unmarshaling t.Languages pointer: %w", err)
43184318+ }
43194319+ }
43204320+43214321+ }
43224322+43234323+ default:
43244324+ // Field doesn't exist on this type, so ignore it
43254325+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
43264326+ return err
43274327+ }
43284328+ }
43294329+ }
43304330+43314331+ return nil
43324332+}
39274333func (t *Pipeline) MarshalCBOR(w io.Writer) error {
39284334 if t == nil {
39294335 _, err := w.Write(cbg.CborNull)
···75607966 }
7561796775627968 t.CreatedAt = string(sval)
79697969+ }
79707970+79717971+ default:
79727972+ // Field doesn't exist on this type, so ignore it
79737973+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
79747974+ return err
79757975+ }
79767976+ }
79777977+ }
79787978+79797979+ return nil
79807980+}
79817981+func (t *RepoDiscussion) MarshalCBOR(w io.Writer) error {
79827982+ if t == nil {
79837983+ _, err := w.Write(cbg.CborNull)
79847984+ return err
79857985+ }
79867986+79877987+ cw := cbg.NewCborWriter(w)
79887988+ fieldCount := 8
79897989+79907990+ if t.Body == nil {
79917991+ fieldCount--
79927992+ }
79937993+79947994+ if t.Mentions == nil {
79957995+ fieldCount--
79967996+ }
79977997+79987998+ if t.References == nil {
79997999+ fieldCount--
80008000+ }
80018001+80028002+ if t.TargetChannel == nil {
80038003+ fieldCount--
80048004+ }
80058005+80068006+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
80078007+ return err
80088008+ }
80098009+80108010+ // t.Body (string) (string)
80118011+ if t.Body != nil {
80128012+80138013+ if len("body") > 1000000 {
80148014+ return xerrors.Errorf("Value in field \"body\" was too long")
80158015+ }
80168016+80178017+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
80188018+ return err
80198019+ }
80208020+ if _, err := cw.WriteString(string("body")); err != nil {
80218021+ return err
80228022+ }
80238023+80248024+ if t.Body == nil {
80258025+ if _, err := cw.Write(cbg.CborNull); err != nil {
80268026+ return err
80278027+ }
80288028+ } else {
80298029+ if len(*t.Body) > 1000000 {
80308030+ return xerrors.Errorf("Value in field t.Body was too long")
80318031+ }
80328032+80338033+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil {
80348034+ return err
80358035+ }
80368036+ if _, err := cw.WriteString(string(*t.Body)); err != nil {
80378037+ return err
80388038+ }
80398039+ }
80408040+ }
80418041+80428042+ // t.Repo (string) (string)
80438043+ if len("repo") > 1000000 {
80448044+ return xerrors.Errorf("Value in field \"repo\" was too long")
80458045+ }
80468046+80478047+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
80488048+ return err
80498049+ }
80508050+ if _, err := cw.WriteString(string("repo")); err != nil {
80518051+ return err
80528052+ }
80538053+80548054+ if len(t.Repo) > 1000000 {
80558055+ return xerrors.Errorf("Value in field t.Repo was too long")
80568056+ }
80578057+80588058+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
80598059+ return err
80608060+ }
80618061+ if _, err := cw.WriteString(string(t.Repo)); err != nil {
80628062+ return err
80638063+ }
80648064+80658065+ // t.LexiconTypeID (string) (string)
80668066+ if len("$type") > 1000000 {
80678067+ return xerrors.Errorf("Value in field \"$type\" was too long")
80688068+ }
80698069+80708070+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
80718071+ return err
80728072+ }
80738073+ if _, err := cw.WriteString(string("$type")); err != nil {
80748074+ return err
80758075+ }
80768076+80778077+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion"))); err != nil {
80788078+ return err
80798079+ }
80808080+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion")); err != nil {
80818081+ return err
80828082+ }
80838083+80848084+ // t.Title (string) (string)
80858085+ if len("title") > 1000000 {
80868086+ return xerrors.Errorf("Value in field \"title\" was too long")
80878087+ }
80888088+80898089+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
80908090+ return err
80918091+ }
80928092+ if _, err := cw.WriteString(string("title")); err != nil {
80938093+ return err
80948094+ }
80958095+80968096+ if len(t.Title) > 1000000 {
80978097+ return xerrors.Errorf("Value in field t.Title was too long")
80988098+ }
80998099+81008100+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
81018101+ return err
81028102+ }
81038103+ if _, err := cw.WriteString(string(t.Title)); err != nil {
81048104+ return err
81058105+ }
81068106+81078107+ // t.Mentions ([]string) (slice)
81088108+ if t.Mentions != nil {
81098109+81108110+ if len("mentions") > 1000000 {
81118111+ return xerrors.Errorf("Value in field \"mentions\" was too long")
81128112+ }
81138113+81148114+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
81158115+ return err
81168116+ }
81178117+ if _, err := cw.WriteString(string("mentions")); err != nil {
81188118+ return err
81198119+ }
81208120+81218121+ if len(t.Mentions) > 8192 {
81228122+ return xerrors.Errorf("Slice value in field t.Mentions was too long")
81238123+ }
81248124+81258125+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
81268126+ return err
81278127+ }
81288128+ for _, v := range t.Mentions {
81298129+ if len(v) > 1000000 {
81308130+ return xerrors.Errorf("Value in field v was too long")
81318131+ }
81328132+81338133+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
81348134+ return err
81358135+ }
81368136+ if _, err := cw.WriteString(string(v)); err != nil {
81378137+ return err
81388138+ }
81398139+81408140+ }
81418141+ }
81428142+81438143+ // t.CreatedAt (string) (string)
81448144+ if len("createdAt") > 1000000 {
81458145+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
81468146+ }
81478147+81488148+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
81498149+ return err
81508150+ }
81518151+ if _, err := cw.WriteString(string("createdAt")); err != nil {
81528152+ return err
81538153+ }
81548154+81558155+ if len(t.CreatedAt) > 1000000 {
81568156+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
81578157+ }
81588158+81598159+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
81608160+ return err
81618161+ }
81628162+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
81638163+ return err
81648164+ }
81658165+81668166+ // t.References ([]string) (slice)
81678167+ if t.References != nil {
81688168+81698169+ if len("references") > 1000000 {
81708170+ return xerrors.Errorf("Value in field \"references\" was too long")
81718171+ }
81728172+81738173+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
81748174+ return err
81758175+ }
81768176+ if _, err := cw.WriteString(string("references")); err != nil {
81778177+ return err
81788178+ }
81798179+81808180+ if len(t.References) > 8192 {
81818181+ return xerrors.Errorf("Slice value in field t.References was too long")
81828182+ }
81838183+81848184+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
81858185+ return err
81868186+ }
81878187+ for _, v := range t.References {
81888188+ if len(v) > 1000000 {
81898189+ return xerrors.Errorf("Value in field v was too long")
81908190+ }
81918191+81928192+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
81938193+ return err
81948194+ }
81958195+ if _, err := cw.WriteString(string(v)); err != nil {
81968196+ return err
81978197+ }
81988198+81998199+ }
82008200+ }
82018201+82028202+ // t.TargetChannel (string) (string)
82038203+ if t.TargetChannel != nil {
82048204+82058205+ if len("targetChannel") > 1000000 {
82068206+ return xerrors.Errorf("Value in field \"targetChannel\" was too long")
82078207+ }
82088208+82098209+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetChannel"))); err != nil {
82108210+ return err
82118211+ }
82128212+ if _, err := cw.WriteString(string("targetChannel")); err != nil {
82138213+ return err
82148214+ }
82158215+82168216+ if t.TargetChannel == nil {
82178217+ if _, err := cw.Write(cbg.CborNull); err != nil {
82188218+ return err
82198219+ }
82208220+ } else {
82218221+ if len(*t.TargetChannel) > 1000000 {
82228222+ return xerrors.Errorf("Value in field t.TargetChannel was too long")
82238223+ }
82248224+82258225+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.TargetChannel))); err != nil {
82268226+ return err
82278227+ }
82288228+ if _, err := cw.WriteString(string(*t.TargetChannel)); err != nil {
82298229+ return err
82308230+ }
82318231+ }
82328232+ }
82338233+ return nil
82348234+}
82358235+82368236+func (t *RepoDiscussion) UnmarshalCBOR(r io.Reader) (err error) {
82378237+ *t = RepoDiscussion{}
82388238+82398239+ cr := cbg.NewCborReader(r)
82408240+82418241+ maj, extra, err := cr.ReadHeader()
82428242+ if err != nil {
82438243+ return err
82448244+ }
82458245+ defer func() {
82468246+ if err == io.EOF {
82478247+ err = io.ErrUnexpectedEOF
82488248+ }
82498249+ }()
82508250+82518251+ if maj != cbg.MajMap {
82528252+ return fmt.Errorf("cbor input should be of type map")
82538253+ }
82548254+82558255+ if extra > cbg.MaxLength {
82568256+ return fmt.Errorf("RepoDiscussion: map struct too large (%d)", extra)
82578257+ }
82588258+82598259+ n := extra
82608260+82618261+ nameBuf := make([]byte, 13)
82628262+ for i := uint64(0); i < n; i++ {
82638263+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
82648264+ if err != nil {
82658265+ return err
82668266+ }
82678267+82688268+ if !ok {
82698269+ // Field doesn't exist on this type, so ignore it
82708270+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
82718271+ return err
82728272+ }
82738273+ continue
82748274+ }
82758275+82768276+ switch string(nameBuf[:nameLen]) {
82778277+ // t.Body (string) (string)
82788278+ case "body":
82798279+82808280+ {
82818281+ b, err := cr.ReadByte()
82828282+ if err != nil {
82838283+ return err
82848284+ }
82858285+ if b != cbg.CborNull[0] {
82868286+ if err := cr.UnreadByte(); err != nil {
82878287+ return err
82888288+ }
82898289+82908290+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
82918291+ if err != nil {
82928292+ return err
82938293+ }
82948294+82958295+ t.Body = (*string)(&sval)
82968296+ }
82978297+ }
82988298+ // t.Repo (string) (string)
82998299+ case "repo":
83008300+83018301+ {
83028302+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83038303+ if err != nil {
83048304+ return err
83058305+ }
83068306+83078307+ t.Repo = string(sval)
83088308+ }
83098309+ // t.LexiconTypeID (string) (string)
83108310+ case "$type":
83118311+83128312+ {
83138313+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83148314+ if err != nil {
83158315+ return err
83168316+ }
83178317+83188318+ t.LexiconTypeID = string(sval)
83198319+ }
83208320+ // t.Title (string) (string)
83218321+ case "title":
83228322+83238323+ {
83248324+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83258325+ if err != nil {
83268326+ return err
83278327+ }
83288328+83298329+ t.Title = string(sval)
83308330+ }
83318331+ // t.Mentions ([]string) (slice)
83328332+ case "mentions":
83338333+83348334+ maj, extra, err = cr.ReadHeader()
83358335+ if err != nil {
83368336+ return err
83378337+ }
83388338+83398339+ if extra > 8192 {
83408340+ return fmt.Errorf("t.Mentions: array too large (%d)", extra)
83418341+ }
83428342+83438343+ if maj != cbg.MajArray {
83448344+ return fmt.Errorf("expected cbor array")
83458345+ }
83468346+83478347+ if extra > 0 {
83488348+ t.Mentions = make([]string, extra)
83498349+ }
83508350+83518351+ for i := 0; i < int(extra); i++ {
83528352+ {
83538353+ var maj byte
83548354+ var extra uint64
83558355+ var err error
83568356+ _ = maj
83578357+ _ = extra
83588358+ _ = err
83598359+83608360+ {
83618361+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83628362+ if err != nil {
83638363+ return err
83648364+ }
83658365+83668366+ t.Mentions[i] = string(sval)
83678367+ }
83688368+83698369+ }
83708370+ }
83718371+ // t.CreatedAt (string) (string)
83728372+ case "createdAt":
83738373+83748374+ {
83758375+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83768376+ if err != nil {
83778377+ return err
83788378+ }
83798379+83808380+ t.CreatedAt = string(sval)
83818381+ }
83828382+ // t.References ([]string) (slice)
83838383+ case "references":
83848384+83858385+ maj, extra, err = cr.ReadHeader()
83868386+ if err != nil {
83878387+ return err
83888388+ }
83898389+83908390+ if extra > 8192 {
83918391+ return fmt.Errorf("t.References: array too large (%d)", extra)
83928392+ }
83938393+83948394+ if maj != cbg.MajArray {
83958395+ return fmt.Errorf("expected cbor array")
83968396+ }
83978397+83988398+ if extra > 0 {
83998399+ t.References = make([]string, extra)
84008400+ }
84018401+84028402+ for i := 0; i < int(extra); i++ {
84038403+ {
84048404+ var maj byte
84058405+ var extra uint64
84068406+ var err error
84078407+ _ = maj
84088408+ _ = extra
84098409+ _ = err
84108410+84118411+ {
84128412+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
84138413+ if err != nil {
84148414+ return err
84158415+ }
84168416+84178417+ t.References[i] = string(sval)
84188418+ }
84198419+84208420+ }
84218421+ }
84228422+ // t.TargetChannel (string) (string)
84238423+ case "targetChannel":
84248424+84258425+ {
84268426+ b, err := cr.ReadByte()
84278427+ if err != nil {
84288428+ return err
84298429+ }
84308430+ if b != cbg.CborNull[0] {
84318431+ if err := cr.UnreadByte(); err != nil {
84328432+ return err
84338433+ }
84348434+84358435+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
84368436+ if err != nil {
84378437+ return err
84388438+ }
84398439+84408440+ t.TargetChannel = (*string)(&sval)
84418441+ }
84428442+ }
84438443+84448444+ default:
84458445+ // Field doesn't exist on this type, so ignore it
84468446+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
84478447+ return err
84488448+ }
84498449+ }
84508450+ }
84518451+84528452+ return nil
84538453+}
84548454+func (t *RepoDiscussionComment) MarshalCBOR(w io.Writer) error {
84558455+ if t == nil {
84568456+ _, err := w.Write(cbg.CborNull)
84578457+ return err
84588458+ }
84598459+84608460+ cw := cbg.NewCborWriter(w)
84618461+ fieldCount := 7
84628462+84638463+ if t.Mentions == nil {
84648464+ fieldCount--
84658465+ }
84668466+84678467+ if t.References == nil {
84688468+ fieldCount--
84698469+ }
84708470+84718471+ if t.ReplyTo == nil {
84728472+ fieldCount--
84738473+ }
84748474+84758475+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
84768476+ return err
84778477+ }
84788478+84798479+ // t.Body (string) (string)
84808480+ if len("body") > 1000000 {
84818481+ return xerrors.Errorf("Value in field \"body\" was too long")
84828482+ }
84838483+84848484+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
84858485+ return err
84868486+ }
84878487+ if _, err := cw.WriteString(string("body")); err != nil {
84888488+ return err
84898489+ }
84908490+84918491+ if len(t.Body) > 1000000 {
84928492+ return xerrors.Errorf("Value in field t.Body was too long")
84938493+ }
84948494+84958495+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil {
84968496+ return err
84978497+ }
84988498+ if _, err := cw.WriteString(string(t.Body)); err != nil {
84998499+ return err
85008500+ }
85018501+85028502+ // t.LexiconTypeID (string) (string)
85038503+ if len("$type") > 1000000 {
85048504+ return xerrors.Errorf("Value in field \"$type\" was too long")
85058505+ }
85068506+85078507+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
85088508+ return err
85098509+ }
85108510+ if _, err := cw.WriteString(string("$type")); err != nil {
85118511+ return err
85128512+ }
85138513+85148514+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion.comment"))); err != nil {
85158515+ return err
85168516+ }
85178517+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion.comment")); err != nil {
85188518+ return err
85198519+ }
85208520+85218521+ // t.ReplyTo (string) (string)
85228522+ if t.ReplyTo != nil {
85238523+85248524+ if len("replyTo") > 1000000 {
85258525+ return xerrors.Errorf("Value in field \"replyTo\" was too long")
85268526+ }
85278527+85288528+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil {
85298529+ return err
85308530+ }
85318531+ if _, err := cw.WriteString(string("replyTo")); err != nil {
85328532+ return err
85338533+ }
85348534+85358535+ if t.ReplyTo == nil {
85368536+ if _, err := cw.Write(cbg.CborNull); err != nil {
85378537+ return err
85388538+ }
85398539+ } else {
85408540+ if len(*t.ReplyTo) > 1000000 {
85418541+ return xerrors.Errorf("Value in field t.ReplyTo was too long")
85428542+ }
85438543+85448544+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil {
85458545+ return err
85468546+ }
85478547+ if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil {
85488548+ return err
85498549+ }
85508550+ }
85518551+ }
85528552+85538553+ // t.Mentions ([]string) (slice)
85548554+ if t.Mentions != nil {
85558555+85568556+ if len("mentions") > 1000000 {
85578557+ return xerrors.Errorf("Value in field \"mentions\" was too long")
85588558+ }
85598559+85608560+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
85618561+ return err
85628562+ }
85638563+ if _, err := cw.WriteString(string("mentions")); err != nil {
85648564+ return err
85658565+ }
85668566+85678567+ if len(t.Mentions) > 8192 {
85688568+ return xerrors.Errorf("Slice value in field t.Mentions was too long")
85698569+ }
85708570+85718571+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
85728572+ return err
85738573+ }
85748574+ for _, v := range t.Mentions {
85758575+ if len(v) > 1000000 {
85768576+ return xerrors.Errorf("Value in field v was too long")
85778577+ }
85788578+85798579+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
85808580+ return err
85818581+ }
85828582+ if _, err := cw.WriteString(string(v)); err != nil {
85838583+ return err
85848584+ }
85858585+85868586+ }
85878587+ }
85888588+85898589+ // t.CreatedAt (string) (string)
85908590+ if len("createdAt") > 1000000 {
85918591+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
85928592+ }
85938593+85948594+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
85958595+ return err
85968596+ }
85978597+ if _, err := cw.WriteString(string("createdAt")); err != nil {
85988598+ return err
85998599+ }
86008600+86018601+ if len(t.CreatedAt) > 1000000 {
86028602+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
86038603+ }
86048604+86058605+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
86068606+ return err
86078607+ }
86088608+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
86098609+ return err
86108610+ }
86118611+86128612+ // t.Discussion (string) (string)
86138613+ if len("discussion") > 1000000 {
86148614+ return xerrors.Errorf("Value in field \"discussion\" was too long")
86158615+ }
86168616+86178617+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("discussion"))); err != nil {
86188618+ return err
86198619+ }
86208620+ if _, err := cw.WriteString(string("discussion")); err != nil {
86218621+ return err
86228622+ }
86238623+86248624+ if len(t.Discussion) > 1000000 {
86258625+ return xerrors.Errorf("Value in field t.Discussion was too long")
86268626+ }
86278627+86288628+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Discussion))); err != nil {
86298629+ return err
86308630+ }
86318631+ if _, err := cw.WriteString(string(t.Discussion)); err != nil {
86328632+ return err
86338633+ }
86348634+86358635+ // t.References ([]string) (slice)
86368636+ if t.References != nil {
86378637+86388638+ if len("references") > 1000000 {
86398639+ return xerrors.Errorf("Value in field \"references\" was too long")
86408640+ }
86418641+86428642+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
86438643+ return err
86448644+ }
86458645+ if _, err := cw.WriteString(string("references")); err != nil {
86468646+ return err
86478647+ }
86488648+86498649+ if len(t.References) > 8192 {
86508650+ return xerrors.Errorf("Slice value in field t.References was too long")
86518651+ }
86528652+86538653+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
86548654+ return err
86558655+ }
86568656+ for _, v := range t.References {
86578657+ if len(v) > 1000000 {
86588658+ return xerrors.Errorf("Value in field v was too long")
86598659+ }
86608660+86618661+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
86628662+ return err
86638663+ }
86648664+ if _, err := cw.WriteString(string(v)); err != nil {
86658665+ return err
86668666+ }
86678667+86688668+ }
86698669+ }
86708670+ return nil
86718671+}
86728672+86738673+func (t *RepoDiscussionComment) UnmarshalCBOR(r io.Reader) (err error) {
86748674+ *t = RepoDiscussionComment{}
86758675+86768676+ cr := cbg.NewCborReader(r)
86778677+86788678+ maj, extra, err := cr.ReadHeader()
86798679+ if err != nil {
86808680+ return err
86818681+ }
86828682+ defer func() {
86838683+ if err == io.EOF {
86848684+ err = io.ErrUnexpectedEOF
86858685+ }
86868686+ }()
86878687+86888688+ if maj != cbg.MajMap {
86898689+ return fmt.Errorf("cbor input should be of type map")
86908690+ }
86918691+86928692+ if extra > cbg.MaxLength {
86938693+ return fmt.Errorf("RepoDiscussionComment: map struct too large (%d)", extra)
86948694+ }
86958695+86968696+ n := extra
86978697+86988698+ nameBuf := make([]byte, 10)
86998699+ for i := uint64(0); i < n; i++ {
87008700+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
87018701+ if err != nil {
87028702+ return err
87038703+ }
87048704+87058705+ if !ok {
87068706+ // Field doesn't exist on this type, so ignore it
87078707+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
87088708+ return err
87098709+ }
87108710+ continue
87118711+ }
87128712+87138713+ switch string(nameBuf[:nameLen]) {
87148714+ // t.Body (string) (string)
87158715+ case "body":
87168716+87178717+ {
87188718+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
87198719+ if err != nil {
87208720+ return err
87218721+ }
87228722+87238723+ t.Body = string(sval)
87248724+ }
87258725+ // t.LexiconTypeID (string) (string)
87268726+ case "$type":
87278727+87288728+ {
87298729+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
87308730+ if err != nil {
87318731+ return err
87328732+ }
87338733+87348734+ t.LexiconTypeID = string(sval)
87358735+ }
87368736+ // t.ReplyTo (string) (string)
87378737+ case "replyTo":
87388738+87398739+ {
87408740+ b, err := cr.ReadByte()
87418741+ if err != nil {
87428742+ return err
87438743+ }
87448744+ if b != cbg.CborNull[0] {
87458745+ if err := cr.UnreadByte(); err != nil {
87468746+ return err
87478747+ }
87488748+87498749+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
87508750+ if err != nil {
87518751+ return err
87528752+ }
87538753+87548754+ t.ReplyTo = (*string)(&sval)
87558755+ }
87568756+ }
87578757+ // t.Mentions ([]string) (slice)
87588758+ case "mentions":
87598759+87608760+ maj, extra, err = cr.ReadHeader()
87618761+ if err != nil {
87628762+ return err
87638763+ }
87648764+87658765+ if extra > 8192 {
87668766+ return fmt.Errorf("t.Mentions: array too large (%d)", extra)
87678767+ }
87688768+87698769+ if maj != cbg.MajArray {
87708770+ return fmt.Errorf("expected cbor array")
87718771+ }
87728772+87738773+ if extra > 0 {
87748774+ t.Mentions = make([]string, extra)
87758775+ }
87768776+87778777+ for i := 0; i < int(extra); i++ {
87788778+ {
87798779+ var maj byte
87808780+ var extra uint64
87818781+ var err error
87828782+ _ = maj
87838783+ _ = extra
87848784+ _ = err
87858785+87868786+ {
87878787+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
87888788+ if err != nil {
87898789+ return err
87908790+ }
87918791+87928792+ t.Mentions[i] = string(sval)
87938793+ }
87948794+87958795+ }
87968796+ }
87978797+ // t.CreatedAt (string) (string)
87988798+ case "createdAt":
87998799+88008800+ {
88018801+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
88028802+ if err != nil {
88038803+ return err
88048804+ }
88058805+88068806+ t.CreatedAt = string(sval)
88078807+ }
88088808+ // t.Discussion (string) (string)
88098809+ case "discussion":
88108810+88118811+ {
88128812+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
88138813+ if err != nil {
88148814+ return err
88158815+ }
88168816+88178817+ t.Discussion = string(sval)
88188818+ }
88198819+ // t.References ([]string) (slice)
88208820+ case "references":
88218821+88228822+ maj, extra, err = cr.ReadHeader()
88238823+ if err != nil {
88248824+ return err
88258825+ }
88268826+88278827+ if extra > 8192 {
88288828+ return fmt.Errorf("t.References: array too large (%d)", extra)
88298829+ }
88308830+88318831+ if maj != cbg.MajArray {
88328832+ return fmt.Errorf("expected cbor array")
88338833+ }
88348834+88358835+ if extra > 0 {
88368836+ t.References = make([]string, extra)
88378837+ }
88388838+88398839+ for i := 0; i < int(extra); i++ {
88408840+ {
88418841+ var maj byte
88428842+ var extra uint64
88438843+ var err error
88448844+ _ = maj
88458845+ _ = extra
88468846+ _ = err
88478847+88488848+ {
88498849+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
88508850+ if err != nil {
88518851+ return err
88528852+ }
88538853+88548854+ t.References[i] = string(sval)
88558855+ }
88568856+88578857+ }
88588858+ }
88598859+88608860+ default:
88618861+ // Field doesn't exist on this type, so ignore it
88628862+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
88638863+ return err
88648864+ }
88658865+ }
88668866+ }
88678867+88688868+ return nil
88698869+}
88708870+func (t *RepoDiscussionState) MarshalCBOR(w io.Writer) error {
88718871+ if t == nil {
88728872+ _, err := w.Write(cbg.CborNull)
88738873+ return err
88748874+ }
88758875+88768876+ cw := cbg.NewCborWriter(w)
88778877+88788878+ if _, err := cw.Write([]byte{164}); err != nil {
88798879+ return err
88808880+ }
88818881+88828882+ // t.LexiconTypeID (string) (string)
88838883+ if len("$type") > 1000000 {
88848884+ return xerrors.Errorf("Value in field \"$type\" was too long")
88858885+ }
88868886+88878887+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
88888888+ return err
88898889+ }
88908890+ if _, err := cw.WriteString(string("$type")); err != nil {
88918891+ return err
88928892+ }
88938893+88948894+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion.state"))); err != nil {
88958895+ return err
88968896+ }
88978897+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion.state")); err != nil {
88988898+ return err
88998899+ }
89008900+89018901+ // t.State (string) (string)
89028902+ if len("state") > 1000000 {
89038903+ return xerrors.Errorf("Value in field \"state\" was too long")
89048904+ }
89058905+89068906+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil {
89078907+ return err
89088908+ }
89098909+ if _, err := cw.WriteString(string("state")); err != nil {
89108910+ return err
89118911+ }
89128912+89138913+ if len(t.State) > 1000000 {
89148914+ return xerrors.Errorf("Value in field t.State was too long")
89158915+ }
89168916+89178917+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil {
89188918+ return err
89198919+ }
89208920+ if _, err := cw.WriteString(string(t.State)); err != nil {
89218921+ return err
89228922+ }
89238923+89248924+ // t.CreatedAt (string) (string)
89258925+ if len("createdAt") > 1000000 {
89268926+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
89278927+ }
89288928+89298929+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
89308930+ return err
89318931+ }
89328932+ if _, err := cw.WriteString(string("createdAt")); err != nil {
89338933+ return err
89348934+ }
89358935+89368936+ if len(t.CreatedAt) > 1000000 {
89378937+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
89388938+ }
89398939+89408940+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
89418941+ return err
89428942+ }
89438943+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
89448944+ return err
89458945+ }
89468946+89478947+ // t.Discussion (string) (string)
89488948+ if len("discussion") > 1000000 {
89498949+ return xerrors.Errorf("Value in field \"discussion\" was too long")
89508950+ }
89518951+89528952+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("discussion"))); err != nil {
89538953+ return err
89548954+ }
89558955+ if _, err := cw.WriteString(string("discussion")); err != nil {
89568956+ return err
89578957+ }
89588958+89598959+ if len(t.Discussion) > 1000000 {
89608960+ return xerrors.Errorf("Value in field t.Discussion was too long")
89618961+ }
89628962+89638963+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Discussion))); err != nil {
89648964+ return err
89658965+ }
89668966+ if _, err := cw.WriteString(string(t.Discussion)); err != nil {
89678967+ return err
89688968+ }
89698969+ return nil
89708970+}
89718971+89728972+func (t *RepoDiscussionState) UnmarshalCBOR(r io.Reader) (err error) {
89738973+ *t = RepoDiscussionState{}
89748974+89758975+ cr := cbg.NewCborReader(r)
89768976+89778977+ maj, extra, err := cr.ReadHeader()
89788978+ if err != nil {
89798979+ return err
89808980+ }
89818981+ defer func() {
89828982+ if err == io.EOF {
89838983+ err = io.ErrUnexpectedEOF
89848984+ }
89858985+ }()
89868986+89878987+ if maj != cbg.MajMap {
89888988+ return fmt.Errorf("cbor input should be of type map")
89898989+ }
89908990+89918991+ if extra > cbg.MaxLength {
89928992+ return fmt.Errorf("RepoDiscussionState: map struct too large (%d)", extra)
89938993+ }
89948994+89958995+ n := extra
89968996+89978997+ nameBuf := make([]byte, 10)
89988998+ for i := uint64(0); i < n; i++ {
89998999+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
90009000+ if err != nil {
90019001+ return err
90029002+ }
90039003+90049004+ if !ok {
90059005+ // Field doesn't exist on this type, so ignore it
90069006+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
90079007+ return err
90089008+ }
90099009+ continue
90109010+ }
90119011+90129012+ switch string(nameBuf[:nameLen]) {
90139013+ // t.LexiconTypeID (string) (string)
90149014+ case "$type":
90159015+90169016+ {
90179017+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
90189018+ if err != nil {
90199019+ return err
90209020+ }
90219021+90229022+ t.LexiconTypeID = string(sval)
90239023+ }
90249024+ // t.State (string) (string)
90259025+ case "state":
90269026+90279027+ {
90289028+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
90299029+ if err != nil {
90309030+ return err
90319031+ }
90329032+90339033+ t.State = string(sval)
90349034+ }
90359035+ // t.CreatedAt (string) (string)
90369036+ case "createdAt":
90379037+90389038+ {
90399039+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
90409040+ if err != nil {
90419041+ return err
90429042+ }
90439043+90449044+ t.CreatedAt = string(sval)
90459045+ }
90469046+ // t.Discussion (string) (string)
90479047+ case "discussion":
90489048+90499049+ {
90509050+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
90519051+ if err != nil {
90529052+ return err
90539053+ }
90549054+90559055+ t.Discussion = string(sval)
75639056 }
7564905775659058 default:
+30
api/tangled/discussioncomment.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.discussion.comment
66+77+import (
88+ "github.com/bluesky-social/indigo/lex/util"
99+)
1010+1111+const (
1212+ RepoDiscussionCommentNSID = "sh.tangled.repo.discussion.comment"
1313+)
1414+1515+func init() {
1616+ util.RegisterType("sh.tangled.repo.discussion.comment", &RepoDiscussionComment{})
1717+} //
1818+// RECORDTYPE: RepoDiscussionComment
1919+type RepoDiscussionComment struct {
2020+ LexiconTypeID string `json:"$type,const=sh.tangled.repo.discussion.comment" cborgen:"$type,const=sh.tangled.repo.discussion.comment"`
2121+ // body: Comment text
2222+ Body string `json:"body" cborgen:"body"`
2323+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
2424+ // discussion: The discussion this comment belongs to
2525+ Discussion string `json:"discussion" cborgen:"discussion"`
2626+ Mentions []string `json:"mentions,omitempty" cborgen:"mentions,omitempty"`
2727+ References []string `json:"references,omitempty" cborgen:"references,omitempty"`
2828+ // replyTo: If this is a reply, the parent comment's at-uri
2929+ ReplyTo *string `json:"replyTo,omitempty" cborgen:"replyTo,omitempty"`
3030+}
+26
api/tangled/discussionstate.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.discussion.state
66+77+import (
88+ "github.com/bluesky-social/indigo/lex/util"
99+)
1010+1111+const (
1212+ RepoDiscussionStateNSID = "sh.tangled.repo.discussion.state"
1313+)
1414+1515+func init() {
1616+ util.RegisterType("sh.tangled.repo.discussion.state", &RepoDiscussionState{})
1717+} //
1818+// RECORDTYPE: RepoDiscussionState
1919+type RepoDiscussionState struct {
2020+ LexiconTypeID string `json:"$type,const=sh.tangled.repo.discussion.state" cborgen:"$type,const=sh.tangled.repo.discussion.state"`
2121+ CreatedAt string `json:"createdAt" cborgen:"createdAt"`
2222+ // discussion: The discussion this state change applies to
2323+ Discussion string `json:"discussion" cborgen:"discussion"`
2424+ // state: The new state of the discussion
2525+ State string `json:"state" cborgen:"state"`
2626+}
+81
api/tangled/pijulrefUpdate.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.pijul.refUpdate
66+77+import (
88+ "fmt"
99+ "io"
1010+1111+ cid "github.com/ipfs/go-cid"
1212+ cbg "github.com/whyrusleeping/cbor-gen"
1313+1414+ "github.com/bluesky-social/indigo/lex/util"
1515+)
1616+1717+const (
1818+ PijulRefUpdateNSID = "sh.tangled.pijul.refUpdate"
1919+)
2020+2121+func init() {
2222+ util.RegisterType("sh.tangled.pijul.refUpdate", &PijulRefUpdate{})
2323+} //
2424+// RECORDTYPE: PijulRefUpdate
2525+type PijulRefUpdate struct {
2626+ LexiconTypeID string `json:"$type,const=sh.tangled.pijul.refUpdate" cborgen:"$type,const=sh.tangled.pijul.refUpdate"`
2727+ // changes: Base32 change hashes pushed in this operation, in application order
2828+ Changes []string `json:"changes" cborgen:"changes"`
2929+ // channel: Channel that was updated
3030+ Channel string `json:"channel" cborgen:"channel"`
3131+ // committerDid: DID of the pusher
3232+ CommitterDid string `json:"committerDid" cborgen:"committerDid"`
3333+ // languages: Optional map of language name to line count
3434+ Languages *PijulRefUpdate_Languages `json:"languages,omitempty" cborgen:"languages,omitempty"`
3535+ // newState: Pijul Merkle state hash after push
3636+ NewState string `json:"newState" cborgen:"newState"`
3737+ // oldState: Pijul Merkle state hash before push (empty for new channels)
3838+ OldState *string `json:"oldState,omitempty" cborgen:"oldState,omitempty"`
3939+ // repo: AT URI of the repository
4040+ Repo string `json:"repo" cborgen:"repo"`
4141+}
4242+4343+// Map of language name to lines of code
4444+type PijulRefUpdate_Languages struct {
4545+}
4646+4747+func (t *PijulRefUpdate_Languages) MarshalCBOR(w io.Writer) error {
4848+ if t == nil {
4949+ _, err := w.Write(cbg.CborNull)
5050+ return err
5151+ }
5252+ cw := cbg.NewCborWriter(w)
5353+ if err := cw.WriteMajorTypeHeader(cbg.MajMap, 0); err != nil {
5454+ return err
5555+ }
5656+ return nil
5757+}
5858+5959+func (t *PijulRefUpdate_Languages) UnmarshalCBOR(r io.Reader) error {
6060+ *t = PijulRefUpdate_Languages{}
6161+ cr := cbg.NewCborReader(r)
6262+ maj, extra, err := cr.ReadHeader()
6363+ if err != nil {
6464+ return err
6565+ }
6666+ if maj != cbg.MajMap {
6767+ return fmt.Errorf("expected cbor map for PijulRefUpdate_Languages")
6868+ }
6969+ // skip all entries
7070+ for i := uint64(0); i < extra; i++ {
7171+ // skip key
7272+ if err := cbg.ScanForLinks(cr, func(_ cid.Cid) {}); err != nil {
7373+ return err
7474+ }
7575+ // skip value
7676+ if err := cbg.ScanForLinks(cr, func(_ cid.Cid) {}); err != nil {
7777+ return err
7878+ }
7979+ }
8080+ return nil
8181+}
+50
api/tangled/repoapplyChanges.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.applyChanges
66+77+import (
88+ "context"
99+1010+ "github.com/bluesky-social/indigo/lex/util"
1111+)
1212+1313+const (
1414+ RepoApplyChangesNSID = "sh.tangled.repo.applyChanges"
1515+)
1616+1717+// RepoApplyChanges_Input is the input argument to a sh.tangled.repo.applyChanges call.
1818+type RepoApplyChanges_Input struct {
1919+ // changes: List of change hashes to apply (in order)
2020+ Changes []string `json:"changes" cborgen:"changes"`
2121+ // channel: Target channel to apply changes to
2222+ Channel string `json:"channel" cborgen:"channel"`
2323+ // repo: Repository identifier in format 'did:plc:.../repoName'
2424+ Repo string `json:"repo" cborgen:"repo"`
2525+}
2626+2727+// RepoApplyChanges_Output is the output of a sh.tangled.repo.applyChanges call.
2828+type RepoApplyChanges_Output struct {
2929+ // applied: List of successfully applied change hashes
3030+ Applied []string `json:"applied" cborgen:"applied"`
3131+ // failed: List of changes that failed to apply
3232+ Failed []*RepoApplyChanges_Output_Failed_Elem `json:"failed,omitempty" cborgen:"failed,omitempty"`
3333+ // newState: Pijul channel Merkle state hash after applying changes. Empty string if unavailable.
3434+ NewState string `json:"newState,omitempty" cborgen:"newState,omitempty"`
3535+}
3636+3737+type RepoApplyChanges_Output_Failed_Elem struct {
3838+ Error string `json:"error" cborgen:"error"`
3939+ Hash string `json:"hash" cborgen:"hash"`
4040+}
4141+4242+// RepoApplyChanges calls the XRPC method "sh.tangled.repo.applyChanges".
4343+func RepoApplyChanges(ctx context.Context, c util.LexClient, input *RepoApplyChanges_Input) (*RepoApplyChanges_Output, error) {
4444+ var out RepoApplyChanges_Output
4545+ if err := c.LexDo(ctx, util.Procedure, "application/json", "sh.tangled.repo.applyChanges", nil, input, &out); err != nil {
4646+ return nil, err
4747+ }
4848+4949+ return &out, nil
5050+}
+54
api/tangled/repochangeGet.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.changeGet
66+77+import (
88+ "context"
99+1010+ "github.com/bluesky-social/indigo/lex/util"
1111+)
1212+1313+const (
1414+ RepoChangeGetNSID = "sh.tangled.repo.changeGet"
1515+)
1616+1717+// RepoChangeGet_Author is a "author" in the sh.tangled.repo.changeGet schema.
1818+type RepoChangeGet_Author struct {
1919+ Did *string `json:"did,omitempty" cborgen:"did,omitempty"`
2020+ Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
2121+ Name string `json:"name" cborgen:"name"`
2222+}
2323+2424+// RepoChangeGet_Output is the output of a sh.tangled.repo.changeGet call.
2525+type RepoChangeGet_Output struct {
2626+ Authors []*RepoChangeGet_Author `json:"authors" cborgen:"authors"`
2727+ // dependencies: Hashes of changes this change depends on
2828+ Dependencies []string `json:"dependencies,omitempty" cborgen:"dependencies,omitempty"`
2929+ // diff: Raw diff content of the change
3030+ Diff *string `json:"diff,omitempty" cborgen:"diff,omitempty"`
3131+ // hash: Change hash (base32 encoded)
3232+ Hash string `json:"hash" cborgen:"hash"`
3333+ // message: Change description
3434+ Message string `json:"message" cborgen:"message"`
3535+ // timestamp: When the change was recorded
3636+ Timestamp *string `json:"timestamp,omitempty" cborgen:"timestamp,omitempty"`
3737+}
3838+3939+// RepoChangeGet calls the XRPC method "sh.tangled.repo.changeGet".
4040+//
4141+// hash: Change hash to retrieve
4242+// repo: Repository identifier in format 'did:plc:.../repoName'
4343+func RepoChangeGet(ctx context.Context, c util.LexClient, hash string, repo string) (*RepoChangeGet_Output, error) {
4444+ var out RepoChangeGet_Output
4545+4646+ params := map[string]interface{}{}
4747+ params["hash"] = hash
4848+ params["repo"] = repo
4949+ if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.changeGet", params, nil, &out); err != nil {
5050+ return nil, err
5151+ }
5252+5353+ return &out, nil
5454+}
+71
api/tangled/repochangeList.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.changeList
66+77+import (
88+ "context"
99+1010+ "github.com/bluesky-social/indigo/lex/util"
1111+)
1212+1313+const (
1414+ RepoChangeListNSID = "sh.tangled.repo.changeList"
1515+)
1616+1717+// RepoChangeList_Author is a "author" in the sh.tangled.repo.changeList schema.
1818+type RepoChangeList_Author struct {
1919+ Did *string `json:"did,omitempty" cborgen:"did,omitempty"`
2020+ Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
2121+ Name string `json:"name" cborgen:"name"`
2222+}
2323+2424+// RepoChangeList_ChangeEntry is a "changeEntry" in the sh.tangled.repo.changeList schema.
2525+type RepoChangeList_ChangeEntry struct {
2626+ Authors []*RepoChangeList_Author `json:"authors" cborgen:"authors"`
2727+ // dependencies: Hashes of changes this change depends on
2828+ Dependencies []string `json:"dependencies,omitempty" cborgen:"dependencies,omitempty"`
2929+ // hash: Change hash (base32 encoded)
3030+ Hash string `json:"hash" cborgen:"hash"`
3131+ // message: Change description
3232+ Message string `json:"message" cborgen:"message"`
3333+ // timestamp: When the change was recorded
3434+ Timestamp *string `json:"timestamp,omitempty" cborgen:"timestamp,omitempty"`
3535+}
3636+3737+// RepoChangeList_Output is the output of a sh.tangled.repo.changeList call.
3838+type RepoChangeList_Output struct {
3939+ Changes []*RepoChangeList_ChangeEntry `json:"changes" cborgen:"changes"`
4040+ Channel *string `json:"channel,omitempty" cborgen:"channel,omitempty"`
4141+ Page int64 `json:"page" cborgen:"page"`
4242+ Per_page int64 `json:"per_page" cborgen:"per_page"`
4343+ Total int64 `json:"total" cborgen:"total"`
4444+}
4545+4646+// RepoChangeList calls the XRPC method "sh.tangled.repo.changeList".
4747+//
4848+// channel: Pijul channel name (defaults to main channel)
4949+// cursor: Pagination cursor (offset)
5050+// limit: Maximum number of changes to return
5151+// repo: Repository identifier in format 'did:plc:.../repoName'
5252+func RepoChangeList(ctx context.Context, c util.LexClient, channel string, cursor string, limit int64, repo string) (*RepoChangeList_Output, error) {
5353+ var out RepoChangeList_Output
5454+5555+ params := map[string]interface{}{}
5656+ if channel != "" {
5757+ params["channel"] = channel
5858+ }
5959+ if cursor != "" {
6060+ params["cursor"] = cursor
6161+ }
6262+ if limit != 0 {
6363+ params["limit"] = limit
6464+ }
6565+ params["repo"] = repo
6666+ if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.changeList", params, nil, &out); err != nil {
6767+ return nil, err
6868+ }
6969+7070+ return &out, nil
7171+}
+51
api/tangled/repochannelList.go
···11+// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
22+33+package tangled
44+55+// schema: sh.tangled.repo.channelList
66+77+import (
88+ "context"
99+1010+ "github.com/bluesky-social/indigo/lex/util"
1111+)
1212+1313+const (
1414+ RepoChannelListNSID = "sh.tangled.repo.channelList"
1515+)
1616+1717+// RepoChannelList_Channel is a "channel" in the sh.tangled.repo.channelList schema.
1818+type RepoChannelList_Channel struct {
1919+ // is_current: Whether this is the currently active channel
2020+ Is_current *bool `json:"is_current,omitempty" cborgen:"is_current,omitempty"`
2121+ // name: Channel name
2222+ Name string `json:"name" cborgen:"name"`
2323+}
2424+2525+// RepoChannelList_Output is the output of a sh.tangled.repo.channelList call.
2626+type RepoChannelList_Output struct {
2727+ Channels []*RepoChannelList_Channel `json:"channels" cborgen:"channels"`
2828+}
2929+3030+// RepoChannelList calls the XRPC method "sh.tangled.repo.channelList".
3131+//
3232+// cursor: Pagination cursor (offset)
3333+// limit: Maximum number of channels to return
3434+// repo: Repository identifier in format 'did:plc:.../repoName'
3535+func RepoChannelList(ctx context.Context, c util.LexClient, cursor string, limit int64, repo string) (*RepoChannelList_Output, error) {
3636+ var out RepoChannelList_Output
3737+3838+ params := map[string]interface{}{}
3939+ if cursor != "" {
4040+ params["cursor"] = cursor
4141+ }
4242+ if limit != 0 {
4343+ params["limit"] = limit
4444+ }
4545+ params["repo"] = repo
4646+ if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.channelList", params, nil, &out); err != nil {
4747+ return nil, err
4848+ }
4949+5050+ return &out, nil
5151+}
+2
api/tangled/repocreate.go
···2626 Rkey string `json:"rkey" cborgen:"rkey"`
2727 // source: A source URL to clone from, populate this when forking or importing a repository.
2828 Source *string `json:"source,omitempty" cborgen:"source,omitempty"`
2929+ // vcs: Version control system to use for the repository (git or pijul).
3030+ Vcs *string `json:"vcs,omitempty" cborgen:"vcs,omitempty"`
2931}
30323133// RepoCreate_Output is the output of a sh.tangled.repo.create call.
···1010 {{ if gt (len .BranchesTrunc) 0 }}
1111 <div class="flex flex-col items-center">
1212 <p class="text-center pt-5 text-gray-400 dark:text-gray-500">
1313- This branch is empty. Other branches in this repository are populated:
1313+ This {{ if .RepoInfo.IsPijul }}channel{{ else }}branch{{ end }} is empty. Other {{ if .RepoInfo.IsPijul }}channels{{ else }}branches{{ end }} in this repository are populated:
1414 </p>
1515 <div class="mt-4 grid grid-cols-1 divide-y divide-gray-200 dark:divide-gray-700 rounded border border-gray-200 dark:border-gray-700 w-full md:w-1/2">
1616 {{ range $br := .BranchesTrunc }}
···9797 <div class="col-span-1 md:col-span-2">
9898 <h2 class="text-sm pb-2 uppercase font-bold">Default Labels</h2>
9999 <p class="text-gray-500 dark:text-gray-400">
100100- Manage your issues and pulls by creating labels to categorize them. Only
100100+ Manage your {{ if .RepoInfo.IsPijul }}discussions{{ else }}issues and pulls{{ end }} by creating labels to categorize them. Only
101101 repository owners may configure labels. You may choose to subscribe to
102102 default labels, or create entirely custom labels.
103103 <p>
···240240 </div>
241241 {{ end }}
242242{{ end }}
243243-
···8080 id integer primary key autoincrement,
8181 name text unique
8282 );
8383+8484+ create table if not exists pijul_signing_keys (
8585+ public_key text primary key,
8686+ did text not null,
8787+ created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')),
8888+ foreign key (did) references known_dids(did) on delete cascade
8989+ );
8390 `)
8491 if err != nil {
8592 return nil, err
+54
knotserver/db/pijulkeys.go
···11+package db
22+33+import "strings"
44+55+// StorePijulSigningKey stores a verified pijul public key → DID mapping.
66+func (d *DB) StorePijulSigningKey(publicKey, did string) error {
77+ _, err := d.db.Exec(`
88+ insert or replace into pijul_signing_keys (public_key, did)
99+ values (?, ?)
1010+ `, publicKey, did)
1111+ return err
1212+}
1313+1414+// GetDidForPijulKey returns the DID associated with a pijul public key.
1515+func (d *DB) GetDidForPijulKey(publicKey string) (string, error) {
1616+ var did string
1717+ err := d.db.QueryRow(`
1818+ select did from pijul_signing_keys where public_key = ?
1919+ `, publicKey).Scan(&did)
2020+ return did, err
2121+}
2222+2323+// GetPijulKeyToDid returns a map of pijul public key → DID for the given keys.
2424+func (d *DB) GetPijulKeyToDid(keys []string) (map[string]string, error) {
2525+ if len(keys) == 0 {
2626+ return make(map[string]string), nil
2727+ }
2828+2929+ placeholders := make([]string, len(keys))
3030+ args := make([]any, len(keys))
3131+ for i, k := range keys {
3232+ placeholders[i] = "?"
3333+ args[i] = k
3434+ }
3535+3636+ rows, err := d.db.Query(`
3737+ select public_key, did from pijul_signing_keys
3838+ where public_key in (`+strings.Join(placeholders, ",")+`)
3939+ `, args...)
4040+ if err != nil {
4141+ return nil, err
4242+ }
4343+ defer rows.Close()
4444+4545+ result := make(map[string]string)
4646+ for rows.Next() {
4747+ var key, did string
4848+ if err := rows.Scan(&key, &did); err != nil {
4949+ return nil, err
5050+ }
5151+ result[key] = did
5252+ }
5353+ return result, rows.Err()
5454+}
+5
knotserver/git/git.go
···8080 return g.h
8181}
82828383+// Path returns the on-disk path of the repository.
8484+func (g *GitRepo) Path() string {
8585+ return g.path
8686+}
8787+8388// re-open a repository and update references
8489func (g *GitRepo) Refresh() error {
8590 refreshed, err := PlainOpen(g.path)
···11+package vcs
22+33+import (
44+ "context"
55+ "errors"
66+ "io"
77+88+ "tangled.org/core/knotserver/git"
99+ "tangled.org/core/knotserver/pijul"
1010+)
1111+1212+// ErrBinaryFile is returned by FileContentN when the file appears to be binary.
1313+// It matches both git.ErrBinaryFile and pijul.ErrBinaryFile.
1414+var ErrBinaryFile = errors.New("binary file")
1515+1616+// IsBinaryFileError returns true if the error indicates a binary file,
1717+// matching against both the vcs, git, and pijul error types.
1818+func IsBinaryFileError(err error) bool {
1919+ return errors.Is(err, ErrBinaryFile) ||
2020+ errors.Is(err, git.ErrBinaryFile) ||
2121+ errors.Is(err, pijul.ErrBinaryFile)
2222+}
2323+2424+// ReadRepo provides read-only access to a VCS repository, abstracting
2525+// over git and pijul.
2626+type ReadRepo interface {
2727+ // VCSType returns "git" or "pijul".
2828+ VCSType() string
2929+3030+ // Path returns the on-disk path of the repository.
3131+ Path() string
3232+3333+ // History returns history entries (commits/changes) with pagination.
3434+ History(offset, limit int) ([]HistoryEntry, error)
3535+3636+ // TotalHistoryEntries returns the total count of commits/changes.
3737+ TotalHistoryEntries() (int, error)
3838+3939+ // HistoryEntry returns a single commit/change by hash.
4040+ HistoryEntry(hash string) (*HistoryEntry, error)
4141+4242+ // Branches returns branches/channels with optional pagination.
4343+ Branches(opts *PaginationOpts) ([]BranchInfo, error)
4444+4545+ // DefaultBranch returns the name of the default branch/channel.
4646+ DefaultBranch() (string, error)
4747+4848+ // FileTree returns the directory listing at the given path.
4949+ FileTree(ctx context.Context, path string) ([]TreeEntry, error)
5050+5151+ // FileContentN reads up to cap bytes of a file, returning ErrBinaryFile
5252+ // if the file appears to be binary.
5353+ FileContentN(path string, cap int64) ([]byte, error)
5454+5555+ // RawContent reads the full raw content of a file.
5656+ RawContent(path string) ([]byte, error)
5757+5858+ // WriteTar writes a tar archive of the repository to w, prefixing
5959+ // all paths with prefix.
6060+ WriteTar(w io.Writer, prefix string) error
6161+6262+ // Tags returns tags with optional pagination. Pijul repos return nil.
6363+ Tags(opts *PaginationOpts) ([]TagInfo, error)
6464+}
6565+6666+// MutableRepo extends ReadRepo with write operations.
6767+type MutableRepo interface {
6868+ ReadRepo
6969+7070+ // SetDefaultBranch sets the default branch/channel.
7171+ SetDefaultBranch(name string) error
7272+7373+ // DeleteBranch deletes a branch/channel.
7474+ DeleteBranch(name string) error
7575+}
+40
knotserver/vcs/detect.go
···11+package vcs
22+33+import (
44+ "fmt"
55+ "os"
66+ "path/filepath"
77+)
88+99+// IsPijulRepo checks if the given path contains a Pijul repository.
1010+func IsPijulRepo(path string) bool {
1111+ info, err := os.Stat(filepath.Join(path, ".pijul"))
1212+ if err != nil {
1313+ return false
1414+ }
1515+ return info.IsDir()
1616+}
1717+1818+// IsGitRepo checks if the given path contains a Git repository.
1919+func IsGitRepo(path string) bool {
2020+ info, err := os.Stat(filepath.Join(path, ".git"))
2121+ if err != nil {
2222+ // Also check for bare git repos (HEAD file at top level).
2323+ if _, err := os.Stat(filepath.Join(path, "HEAD")); err == nil {
2424+ return true
2525+ }
2626+ return false
2727+ }
2828+ return info.IsDir()
2929+}
3030+3131+// DetectVCS detects whether a path contains a Git or Pijul repository.
3232+func DetectVCS(path string) (string, error) {
3333+ if IsPijulRepo(path) {
3434+ return "pijul", nil
3535+ }
3636+ if IsGitRepo(path) {
3737+ return "git", nil
3838+ }
3939+ return "", fmt.Errorf("no VCS repository found at %s", path)
4040+}
···3434 "type": "string",
3535 "format": "did",
3636 "description": "Optional user-provided did:web to use as the repo identity instead of minting a did:plc."
3737+ },
3838+ "vcs": {
3939+ "type": "string",
4040+ "description": "Version control system to use for the repository (git or pijul)."
3741 }
3842 }
3943 }