···3625362536263626 return nil
36273627}
36283628+func (t *PijulRefUpdate) MarshalCBOR(w io.Writer) error {
36293629+ if t == nil {
36303630+ _, err := w.Write(cbg.CborNull)
36313631+ return err
36323632+ }
36333633+36343634+ cw := cbg.NewCborWriter(w)
36353635+ fieldCount := 7
36363636+36373637+ if t.Languages == nil {
36383638+ fieldCount--
36393639+ }
36403640+36413641+ if t.OldState == nil {
36423642+ fieldCount--
36433643+ }
36443644+36453645+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
36463646+ return err
36473647+ }
36483648+36493649+ // t.Repo (string) (string)
36503650+ if len("repo") > 1000000 {
36513651+ return xerrors.Errorf("Value in field \"repo\" was too long")
36523652+ }
36533653+36543654+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
36553655+ return err
36563656+ }
36573657+ if _, err := cw.WriteString(string("repo")); err != nil {
36583658+ return err
36593659+ }
36603660+36613661+ if len(t.Repo) > 1000000 {
36623662+ return xerrors.Errorf("Value in field t.Repo was too long")
36633663+ }
36643664+36653665+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
36663666+ return err
36673667+ }
36683668+ if _, err := cw.WriteString(string(t.Repo)); err != nil {
36693669+ return err
36703670+ }
36713671+36723672+ // t.LexiconTypeID (string) (string)
36733673+ if len("$type") > 1000000 {
36743674+ return xerrors.Errorf("Value in field \"$type\" was too long")
36753675+ }
36763676+36773677+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
36783678+ return err
36793679+ }
36803680+ if _, err := cw.WriteString(string("$type")); err != nil {
36813681+ return err
36823682+ }
36833683+36843684+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.pijul.refUpdate"))); err != nil {
36853685+ return err
36863686+ }
36873687+ if _, err := cw.WriteString(string("sh.tangled.pijul.refUpdate")); err != nil {
36883688+ return err
36893689+ }
36903690+36913691+ // t.Changes ([]string) (slice)
36923692+ if len("changes") > 1000000 {
36933693+ return xerrors.Errorf("Value in field \"changes\" was too long")
36943694+ }
36953695+36963696+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("changes"))); err != nil {
36973697+ return err
36983698+ }
36993699+ if _, err := cw.WriteString(string("changes")); err != nil {
37003700+ return err
37013701+ }
37023702+37033703+ if len(t.Changes) > 8192 {
37043704+ return xerrors.Errorf("Slice value in field t.Changes was too long")
37053705+ }
37063706+37073707+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Changes))); err != nil {
37083708+ return err
37093709+ }
37103710+ for _, v := range t.Changes {
37113711+ if len(v) > 1000000 {
37123712+ return xerrors.Errorf("Value in field v was too long")
37133713+ }
37143714+37153715+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
37163716+ return err
37173717+ }
37183718+ if _, err := cw.WriteString(string(v)); err != nil {
37193719+ return err
37203720+ }
37213721+37223722+ }
37233723+37243724+ // t.Channel (string) (string)
37253725+ if len("channel") > 1000000 {
37263726+ return xerrors.Errorf("Value in field \"channel\" was too long")
37273727+ }
37283728+37293729+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("channel"))); err != nil {
37303730+ return err
37313731+ }
37323732+ if _, err := cw.WriteString(string("channel")); err != nil {
37333733+ return err
37343734+ }
37353735+37363736+ if len(t.Channel) > 1000000 {
37373737+ return xerrors.Errorf("Value in field t.Channel was too long")
37383738+ }
37393739+37403740+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Channel))); err != nil {
37413741+ return err
37423742+ }
37433743+ if _, err := cw.WriteString(string(t.Channel)); err != nil {
37443744+ return err
37453745+ }
37463746+37473747+ // t.NewState (string) (string)
37483748+ if len("newState") > 1000000 {
37493749+ return xerrors.Errorf("Value in field \"newState\" was too long")
37503750+ }
37513751+37523752+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("newState"))); err != nil {
37533753+ return err
37543754+ }
37553755+ if _, err := cw.WriteString(string("newState")); err != nil {
37563756+ return err
37573757+ }
37583758+37593759+ if len(t.NewState) > 1000000 {
37603760+ return xerrors.Errorf("Value in field t.NewState was too long")
37613761+ }
37623762+37633763+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.NewState))); err != nil {
37643764+ return err
37653765+ }
37663766+ if _, err := cw.WriteString(string(t.NewState)); err != nil {
37673767+ return err
37683768+ }
37693769+37703770+ // t.OldState (string) (string)
37713771+ if t.OldState != nil {
37723772+37733773+ if len("oldState") > 1000000 {
37743774+ return xerrors.Errorf("Value in field \"oldState\" was too long")
37753775+ }
37763776+37773777+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("oldState"))); err != nil {
37783778+ return err
37793779+ }
37803780+ if _, err := cw.WriteString(string("oldState")); err != nil {
37813781+ return err
37823782+ }
37833783+37843784+ if t.OldState == nil {
37853785+ if _, err := cw.Write(cbg.CborNull); err != nil {
37863786+ return err
37873787+ }
37883788+ } else {
37893789+ if len(*t.OldState) > 1000000 {
37903790+ return xerrors.Errorf("Value in field t.OldState was too long")
37913791+ }
37923792+37933793+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.OldState))); err != nil {
37943794+ return err
37953795+ }
37963796+ if _, err := cw.WriteString(string(*t.OldState)); err != nil {
37973797+ return err
37983798+ }
37993799+ }
38003800+ }
38013801+38023802+ // t.Languages (tangled.PijulRefUpdate_Languages) (struct)
38033803+ if t.Languages != nil {
38043804+38053805+ if len("languages") > 1000000 {
38063806+ return xerrors.Errorf("Value in field \"languages\" was too long")
38073807+ }
38083808+38093809+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("languages"))); err != nil {
38103810+ return err
38113811+ }
38123812+ if _, err := cw.WriteString(string("languages")); err != nil {
38133813+ return err
38143814+ }
38153815+38163816+ if err := t.Languages.MarshalCBOR(cw); err != nil {
38173817+ return err
38183818+ }
38193819+ }
38203820+ return nil
38213821+}
38223822+38233823+func (t *PijulRefUpdate) UnmarshalCBOR(r io.Reader) (err error) {
38243824+ *t = PijulRefUpdate{}
38253825+38263826+ cr := cbg.NewCborReader(r)
38273827+38283828+ maj, extra, err := cr.ReadHeader()
38293829+ if err != nil {
38303830+ return err
38313831+ }
38323832+ defer func() {
38333833+ if err == io.EOF {
38343834+ err = io.ErrUnexpectedEOF
38353835+ }
38363836+ }()
38373837+38383838+ if maj != cbg.MajMap {
38393839+ return fmt.Errorf("cbor input should be of type map")
38403840+ }
38413841+38423842+ if extra > cbg.MaxLength {
38433843+ return fmt.Errorf("PijulRefUpdate: map struct too large (%d)", extra)
38443844+ }
38453845+38463846+ n := extra
38473847+38483848+ nameBuf := make([]byte, 9)
38493849+ for i := uint64(0); i < n; i++ {
38503850+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
38513851+ if err != nil {
38523852+ return err
38533853+ }
38543854+38553855+ if !ok {
38563856+ // Field doesn't exist on this type, so ignore it
38573857+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
38583858+ return err
38593859+ }
38603860+ continue
38613861+ }
38623862+38633863+ switch string(nameBuf[:nameLen]) {
38643864+ // t.Repo (string) (string)
38653865+ case "repo":
38663866+38673867+ {
38683868+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
38693869+ if err != nil {
38703870+ return err
38713871+ }
38723872+38733873+ t.Repo = string(sval)
38743874+ }
38753875+ // t.LexiconTypeID (string) (string)
38763876+ case "$type":
38773877+38783878+ {
38793879+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
38803880+ if err != nil {
38813881+ return err
38823882+ }
38833883+38843884+ t.LexiconTypeID = string(sval)
38853885+ }
38863886+ // t.Changes ([]string) (slice)
38873887+ case "changes":
38883888+38893889+ maj, extra, err = cr.ReadHeader()
38903890+ if err != nil {
38913891+ return err
38923892+ }
38933893+38943894+ if extra > 8192 {
38953895+ return fmt.Errorf("t.Changes: array too large (%d)", extra)
38963896+ }
38973897+38983898+ if maj != cbg.MajArray {
38993899+ return fmt.Errorf("expected cbor array")
39003900+ }
39013901+39023902+ if extra > 0 {
39033903+ t.Changes = make([]string, extra)
39043904+ }
39053905+39063906+ for i := 0; i < int(extra); i++ {
39073907+ {
39083908+ var maj byte
39093909+ var extra uint64
39103910+ var err error
39113911+ _ = maj
39123912+ _ = extra
39133913+ _ = err
39143914+39153915+ {
39163916+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
39173917+ if err != nil {
39183918+ return err
39193919+ }
39203920+39213921+ t.Changes[i] = string(sval)
39223922+ }
39233923+39243924+ }
39253925+ }
39263926+ // t.Channel (string) (string)
39273927+ case "channel":
39283928+39293929+ {
39303930+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
39313931+ if err != nil {
39323932+ return err
39333933+ }
39343934+39353935+ t.Channel = string(sval)
39363936+ }
39373937+ // t.NewState (string) (string)
39383938+ case "newState":
39393939+39403940+ {
39413941+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
39423942+ if err != nil {
39433943+ return err
39443944+ }
39453945+39463946+ t.NewState = string(sval)
39473947+ }
39483948+ // t.OldState (string) (string)
39493949+ case "oldState":
39503950+39513951+ {
39523952+ b, err := cr.ReadByte()
39533953+ if err != nil {
39543954+ return err
39553955+ }
39563956+ if b != cbg.CborNull[0] {
39573957+ if err := cr.UnreadByte(); err != nil {
39583958+ return err
39593959+ }
39603960+39613961+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
39623962+ if err != nil {
39633963+ return err
39643964+ }
39653965+39663966+ t.OldState = (*string)(&sval)
39673967+ }
39683968+ }
39693969+ // t.Languages (tangled.PijulRefUpdate_Languages) (struct)
39703970+ case "languages":
39713971+39723972+ {
39733973+39743974+ b, err := cr.ReadByte()
39753975+ if err != nil {
39763976+ return err
39773977+ }
39783978+ if b != cbg.CborNull[0] {
39793979+ if err := cr.UnreadByte(); err != nil {
39803980+ return err
39813981+ }
39823982+ t.Languages = new(PijulRefUpdate_Languages)
39833983+ if err := t.Languages.UnmarshalCBOR(cr); err != nil {
39843984+ return xerrors.Errorf("unmarshaling t.Languages pointer: %w", err)
39853985+ }
39863986+ }
39873987+39883988+ }
39893989+39903990+ default:
39913991+ // Field doesn't exist on this type, so ignore it
39923992+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
39933993+ return err
39943994+ }
39953995+ }
39963996+ }
39973997+39983998+ return nil
39993999+}
36284000func (t *Pipeline) MarshalCBOR(w io.Writer) error {
36294001 if t == nil {
36304002 _, err := w.Write(cbg.CborNull)
···69627334 }
6963733569647336 t.CreatedAt = string(sval)
73377337+ }
73387338+73397339+ default:
73407340+ // Field doesn't exist on this type, so ignore it
73417341+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
73427342+ return err
73437343+ }
73447344+ }
73457345+ }
73467346+73477347+ return nil
73487348+}
73497349+func (t *RepoDiscussion) MarshalCBOR(w io.Writer) error {
73507350+ if t == nil {
73517351+ _, err := w.Write(cbg.CborNull)
73527352+ return err
73537353+ }
73547354+73557355+ cw := cbg.NewCborWriter(w)
73567356+ fieldCount := 8
73577357+73587358+ if t.Body == nil {
73597359+ fieldCount--
73607360+ }
73617361+73627362+ if t.Mentions == nil {
73637363+ fieldCount--
73647364+ }
73657365+73667366+ if t.References == nil {
73677367+ fieldCount--
73687368+ }
73697369+73707370+ if t.TargetChannel == nil {
73717371+ fieldCount--
73727372+ }
73737373+73747374+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
73757375+ return err
73767376+ }
73777377+73787378+ // t.Body (string) (string)
73797379+ if t.Body != nil {
73807380+73817381+ if len("body") > 1000000 {
73827382+ return xerrors.Errorf("Value in field \"body\" was too long")
73837383+ }
73847384+73857385+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
73867386+ return err
73877387+ }
73887388+ if _, err := cw.WriteString(string("body")); err != nil {
73897389+ return err
73907390+ }
73917391+73927392+ if t.Body == nil {
73937393+ if _, err := cw.Write(cbg.CborNull); err != nil {
73947394+ return err
73957395+ }
73967396+ } else {
73977397+ if len(*t.Body) > 1000000 {
73987398+ return xerrors.Errorf("Value in field t.Body was too long")
73997399+ }
74007400+74017401+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Body))); err != nil {
74027402+ return err
74037403+ }
74047404+ if _, err := cw.WriteString(string(*t.Body)); err != nil {
74057405+ return err
74067406+ }
74077407+ }
74087408+ }
74097409+74107410+ // t.Repo (string) (string)
74117411+ if len("repo") > 1000000 {
74127412+ return xerrors.Errorf("Value in field \"repo\" was too long")
74137413+ }
74147414+74157415+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil {
74167416+ return err
74177417+ }
74187418+ if _, err := cw.WriteString(string("repo")); err != nil {
74197419+ return err
74207420+ }
74217421+74227422+ if len(t.Repo) > 1000000 {
74237423+ return xerrors.Errorf("Value in field t.Repo was too long")
74247424+ }
74257425+74267426+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil {
74277427+ return err
74287428+ }
74297429+ if _, err := cw.WriteString(string(t.Repo)); err != nil {
74307430+ return err
74317431+ }
74327432+74337433+ // t.LexiconTypeID (string) (string)
74347434+ if len("$type") > 1000000 {
74357435+ return xerrors.Errorf("Value in field \"$type\" was too long")
74367436+ }
74377437+74387438+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
74397439+ return err
74407440+ }
74417441+ if _, err := cw.WriteString(string("$type")); err != nil {
74427442+ return err
74437443+ }
74447444+74457445+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion"))); err != nil {
74467446+ return err
74477447+ }
74487448+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion")); err != nil {
74497449+ return err
74507450+ }
74517451+74527452+ // t.Title (string) (string)
74537453+ if len("title") > 1000000 {
74547454+ return xerrors.Errorf("Value in field \"title\" was too long")
74557455+ }
74567456+74577457+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("title"))); err != nil {
74587458+ return err
74597459+ }
74607460+ if _, err := cw.WriteString(string("title")); err != nil {
74617461+ return err
74627462+ }
74637463+74647464+ if len(t.Title) > 1000000 {
74657465+ return xerrors.Errorf("Value in field t.Title was too long")
74667466+ }
74677467+74687468+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Title))); err != nil {
74697469+ return err
74707470+ }
74717471+ if _, err := cw.WriteString(string(t.Title)); err != nil {
74727472+ return err
74737473+ }
74747474+74757475+ // t.Mentions ([]string) (slice)
74767476+ if t.Mentions != nil {
74777477+74787478+ if len("mentions") > 1000000 {
74797479+ return xerrors.Errorf("Value in field \"mentions\" was too long")
74807480+ }
74817481+74827482+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
74837483+ return err
74847484+ }
74857485+ if _, err := cw.WriteString(string("mentions")); err != nil {
74867486+ return err
74877487+ }
74887488+74897489+ if len(t.Mentions) > 8192 {
74907490+ return xerrors.Errorf("Slice value in field t.Mentions was too long")
74917491+ }
74927492+74937493+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
74947494+ return err
74957495+ }
74967496+ for _, v := range t.Mentions {
74977497+ if len(v) > 1000000 {
74987498+ return xerrors.Errorf("Value in field v was too long")
74997499+ }
75007500+75017501+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
75027502+ return err
75037503+ }
75047504+ if _, err := cw.WriteString(string(v)); err != nil {
75057505+ return err
75067506+ }
75077507+75087508+ }
75097509+ }
75107510+75117511+ // t.CreatedAt (string) (string)
75127512+ if len("createdAt") > 1000000 {
75137513+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
75147514+ }
75157515+75167516+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
75177517+ return err
75187518+ }
75197519+ if _, err := cw.WriteString(string("createdAt")); err != nil {
75207520+ return err
75217521+ }
75227522+75237523+ if len(t.CreatedAt) > 1000000 {
75247524+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
75257525+ }
75267526+75277527+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
75287528+ return err
75297529+ }
75307530+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
75317531+ return err
75327532+ }
75337533+75347534+ // t.References ([]string) (slice)
75357535+ if t.References != nil {
75367536+75377537+ if len("references") > 1000000 {
75387538+ return xerrors.Errorf("Value in field \"references\" was too long")
75397539+ }
75407540+75417541+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
75427542+ return err
75437543+ }
75447544+ if _, err := cw.WriteString(string("references")); err != nil {
75457545+ return err
75467546+ }
75477547+75487548+ if len(t.References) > 8192 {
75497549+ return xerrors.Errorf("Slice value in field t.References was too long")
75507550+ }
75517551+75527552+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
75537553+ return err
75547554+ }
75557555+ for _, v := range t.References {
75567556+ if len(v) > 1000000 {
75577557+ return xerrors.Errorf("Value in field v was too long")
75587558+ }
75597559+75607560+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
75617561+ return err
75627562+ }
75637563+ if _, err := cw.WriteString(string(v)); err != nil {
75647564+ return err
75657565+ }
75667566+75677567+ }
75687568+ }
75697569+75707570+ // t.TargetChannel (string) (string)
75717571+ if t.TargetChannel != nil {
75727572+75737573+ if len("targetChannel") > 1000000 {
75747574+ return xerrors.Errorf("Value in field \"targetChannel\" was too long")
75757575+ }
75767576+75777577+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetChannel"))); err != nil {
75787578+ return err
75797579+ }
75807580+ if _, err := cw.WriteString(string("targetChannel")); err != nil {
75817581+ return err
75827582+ }
75837583+75847584+ if t.TargetChannel == nil {
75857585+ if _, err := cw.Write(cbg.CborNull); err != nil {
75867586+ return err
75877587+ }
75887588+ } else {
75897589+ if len(*t.TargetChannel) > 1000000 {
75907590+ return xerrors.Errorf("Value in field t.TargetChannel was too long")
75917591+ }
75927592+75937593+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.TargetChannel))); err != nil {
75947594+ return err
75957595+ }
75967596+ if _, err := cw.WriteString(string(*t.TargetChannel)); err != nil {
75977597+ return err
75987598+ }
75997599+ }
76007600+ }
76017601+ return nil
76027602+}
76037603+76047604+func (t *RepoDiscussion) UnmarshalCBOR(r io.Reader) (err error) {
76057605+ *t = RepoDiscussion{}
76067606+76077607+ cr := cbg.NewCborReader(r)
76087608+76097609+ maj, extra, err := cr.ReadHeader()
76107610+ if err != nil {
76117611+ return err
76127612+ }
76137613+ defer func() {
76147614+ if err == io.EOF {
76157615+ err = io.ErrUnexpectedEOF
76167616+ }
76177617+ }()
76187618+76197619+ if maj != cbg.MajMap {
76207620+ return fmt.Errorf("cbor input should be of type map")
76217621+ }
76227622+76237623+ if extra > cbg.MaxLength {
76247624+ return fmt.Errorf("RepoDiscussion: map struct too large (%d)", extra)
76257625+ }
76267626+76277627+ n := extra
76287628+76297629+ nameBuf := make([]byte, 13)
76307630+ for i := uint64(0); i < n; i++ {
76317631+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
76327632+ if err != nil {
76337633+ return err
76347634+ }
76357635+76367636+ if !ok {
76377637+ // Field doesn't exist on this type, so ignore it
76387638+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
76397639+ return err
76407640+ }
76417641+ continue
76427642+ }
76437643+76447644+ switch string(nameBuf[:nameLen]) {
76457645+ // t.Body (string) (string)
76467646+ case "body":
76477647+76487648+ {
76497649+ b, err := cr.ReadByte()
76507650+ if err != nil {
76517651+ return err
76527652+ }
76537653+ if b != cbg.CborNull[0] {
76547654+ if err := cr.UnreadByte(); err != nil {
76557655+ return err
76567656+ }
76577657+76587658+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
76597659+ if err != nil {
76607660+ return err
76617661+ }
76627662+76637663+ t.Body = (*string)(&sval)
76647664+ }
76657665+ }
76667666+ // t.Repo (string) (string)
76677667+ case "repo":
76687668+76697669+ {
76707670+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
76717671+ if err != nil {
76727672+ return err
76737673+ }
76747674+76757675+ t.Repo = string(sval)
76767676+ }
76777677+ // t.LexiconTypeID (string) (string)
76787678+ case "$type":
76797679+76807680+ {
76817681+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
76827682+ if err != nil {
76837683+ return err
76847684+ }
76857685+76867686+ t.LexiconTypeID = string(sval)
76877687+ }
76887688+ // t.Title (string) (string)
76897689+ case "title":
76907690+76917691+ {
76927692+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
76937693+ if err != nil {
76947694+ return err
76957695+ }
76967696+76977697+ t.Title = string(sval)
76987698+ }
76997699+ // t.Mentions ([]string) (slice)
77007700+ case "mentions":
77017701+77027702+ maj, extra, err = cr.ReadHeader()
77037703+ if err != nil {
77047704+ return err
77057705+ }
77067706+77077707+ if extra > 8192 {
77087708+ return fmt.Errorf("t.Mentions: array too large (%d)", extra)
77097709+ }
77107710+77117711+ if maj != cbg.MajArray {
77127712+ return fmt.Errorf("expected cbor array")
77137713+ }
77147714+77157715+ if extra > 0 {
77167716+ t.Mentions = make([]string, extra)
77177717+ }
77187718+77197719+ for i := 0; i < int(extra); i++ {
77207720+ {
77217721+ var maj byte
77227722+ var extra uint64
77237723+ var err error
77247724+ _ = maj
77257725+ _ = extra
77267726+ _ = err
77277727+77287728+ {
77297729+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
77307730+ if err != nil {
77317731+ return err
77327732+ }
77337733+77347734+ t.Mentions[i] = string(sval)
77357735+ }
77367736+77377737+ }
77387738+ }
77397739+ // t.CreatedAt (string) (string)
77407740+ case "createdAt":
77417741+77427742+ {
77437743+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
77447744+ if err != nil {
77457745+ return err
77467746+ }
77477747+77487748+ t.CreatedAt = string(sval)
77497749+ }
77507750+ // t.References ([]string) (slice)
77517751+ case "references":
77527752+77537753+ maj, extra, err = cr.ReadHeader()
77547754+ if err != nil {
77557755+ return err
77567756+ }
77577757+77587758+ if extra > 8192 {
77597759+ return fmt.Errorf("t.References: array too large (%d)", extra)
77607760+ }
77617761+77627762+ if maj != cbg.MajArray {
77637763+ return fmt.Errorf("expected cbor array")
77647764+ }
77657765+77667766+ if extra > 0 {
77677767+ t.References = make([]string, extra)
77687768+ }
77697769+77707770+ for i := 0; i < int(extra); i++ {
77717771+ {
77727772+ var maj byte
77737773+ var extra uint64
77747774+ var err error
77757775+ _ = maj
77767776+ _ = extra
77777777+ _ = err
77787778+77797779+ {
77807780+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
77817781+ if err != nil {
77827782+ return err
77837783+ }
77847784+77857785+ t.References[i] = string(sval)
77867786+ }
77877787+77887788+ }
77897789+ }
77907790+ // t.TargetChannel (string) (string)
77917791+ case "targetChannel":
77927792+77937793+ {
77947794+ b, err := cr.ReadByte()
77957795+ if err != nil {
77967796+ return err
77977797+ }
77987798+ if b != cbg.CborNull[0] {
77997799+ if err := cr.UnreadByte(); err != nil {
78007800+ return err
78017801+ }
78027802+78037803+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
78047804+ if err != nil {
78057805+ return err
78067806+ }
78077807+78087808+ t.TargetChannel = (*string)(&sval)
78097809+ }
78107810+ }
78117811+78127812+ default:
78137813+ // Field doesn't exist on this type, so ignore it
78147814+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
78157815+ return err
78167816+ }
78177817+ }
78187818+ }
78197819+78207820+ return nil
78217821+}
78227822+func (t *RepoDiscussionComment) MarshalCBOR(w io.Writer) error {
78237823+ if t == nil {
78247824+ _, err := w.Write(cbg.CborNull)
78257825+ return err
78267826+ }
78277827+78287828+ cw := cbg.NewCborWriter(w)
78297829+ fieldCount := 7
78307830+78317831+ if t.Mentions == nil {
78327832+ fieldCount--
78337833+ }
78347834+78357835+ if t.References == nil {
78367836+ fieldCount--
78377837+ }
78387838+78397839+ if t.ReplyTo == nil {
78407840+ fieldCount--
78417841+ }
78427842+78437843+ if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
78447844+ return err
78457845+ }
78467846+78477847+ // t.Body (string) (string)
78487848+ if len("body") > 1000000 {
78497849+ return xerrors.Errorf("Value in field \"body\" was too long")
78507850+ }
78517851+78527852+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("body"))); err != nil {
78537853+ return err
78547854+ }
78557855+ if _, err := cw.WriteString(string("body")); err != nil {
78567856+ return err
78577857+ }
78587858+78597859+ if len(t.Body) > 1000000 {
78607860+ return xerrors.Errorf("Value in field t.Body was too long")
78617861+ }
78627862+78637863+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Body))); err != nil {
78647864+ return err
78657865+ }
78667866+ if _, err := cw.WriteString(string(t.Body)); err != nil {
78677867+ return err
78687868+ }
78697869+78707870+ // t.LexiconTypeID (string) (string)
78717871+ if len("$type") > 1000000 {
78727872+ return xerrors.Errorf("Value in field \"$type\" was too long")
78737873+ }
78747874+78757875+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
78767876+ return err
78777877+ }
78787878+ if _, err := cw.WriteString(string("$type")); err != nil {
78797879+ return err
78807880+ }
78817881+78827882+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion.comment"))); err != nil {
78837883+ return err
78847884+ }
78857885+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion.comment")); err != nil {
78867886+ return err
78877887+ }
78887888+78897889+ // t.ReplyTo (string) (string)
78907890+ if t.ReplyTo != nil {
78917891+78927892+ if len("replyTo") > 1000000 {
78937893+ return xerrors.Errorf("Value in field \"replyTo\" was too long")
78947894+ }
78957895+78967896+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("replyTo"))); err != nil {
78977897+ return err
78987898+ }
78997899+ if _, err := cw.WriteString(string("replyTo")); err != nil {
79007900+ return err
79017901+ }
79027902+79037903+ if t.ReplyTo == nil {
79047904+ if _, err := cw.Write(cbg.CborNull); err != nil {
79057905+ return err
79067906+ }
79077907+ } else {
79087908+ if len(*t.ReplyTo) > 1000000 {
79097909+ return xerrors.Errorf("Value in field t.ReplyTo was too long")
79107910+ }
79117911+79127912+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.ReplyTo))); err != nil {
79137913+ return err
79147914+ }
79157915+ if _, err := cw.WriteString(string(*t.ReplyTo)); err != nil {
79167916+ return err
79177917+ }
79187918+ }
79197919+ }
79207920+79217921+ // t.Mentions ([]string) (slice)
79227922+ if t.Mentions != nil {
79237923+79247924+ if len("mentions") > 1000000 {
79257925+ return xerrors.Errorf("Value in field \"mentions\" was too long")
79267926+ }
79277927+79287928+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("mentions"))); err != nil {
79297929+ return err
79307930+ }
79317931+ if _, err := cw.WriteString(string("mentions")); err != nil {
79327932+ return err
79337933+ }
79347934+79357935+ if len(t.Mentions) > 8192 {
79367936+ return xerrors.Errorf("Slice value in field t.Mentions was too long")
79377937+ }
79387938+79397939+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Mentions))); err != nil {
79407940+ return err
79417941+ }
79427942+ for _, v := range t.Mentions {
79437943+ if len(v) > 1000000 {
79447944+ return xerrors.Errorf("Value in field v was too long")
79457945+ }
79467946+79477947+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
79487948+ return err
79497949+ }
79507950+ if _, err := cw.WriteString(string(v)); err != nil {
79517951+ return err
79527952+ }
79537953+79547954+ }
79557955+ }
79567956+79577957+ // t.CreatedAt (string) (string)
79587958+ if len("createdAt") > 1000000 {
79597959+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
79607960+ }
79617961+79627962+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
79637963+ return err
79647964+ }
79657965+ if _, err := cw.WriteString(string("createdAt")); err != nil {
79667966+ return err
79677967+ }
79687968+79697969+ if len(t.CreatedAt) > 1000000 {
79707970+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
79717971+ }
79727972+79737973+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
79747974+ return err
79757975+ }
79767976+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
79777977+ return err
79787978+ }
79797979+79807980+ // t.Discussion (string) (string)
79817981+ if len("discussion") > 1000000 {
79827982+ return xerrors.Errorf("Value in field \"discussion\" was too long")
79837983+ }
79847984+79857985+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("discussion"))); err != nil {
79867986+ return err
79877987+ }
79887988+ if _, err := cw.WriteString(string("discussion")); err != nil {
79897989+ return err
79907990+ }
79917991+79927992+ if len(t.Discussion) > 1000000 {
79937993+ return xerrors.Errorf("Value in field t.Discussion was too long")
79947994+ }
79957995+79967996+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Discussion))); err != nil {
79977997+ return err
79987998+ }
79997999+ if _, err := cw.WriteString(string(t.Discussion)); err != nil {
80008000+ return err
80018001+ }
80028002+80038003+ // t.References ([]string) (slice)
80048004+ if t.References != nil {
80058005+80068006+ if len("references") > 1000000 {
80078007+ return xerrors.Errorf("Value in field \"references\" was too long")
80088008+ }
80098009+80108010+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("references"))); err != nil {
80118011+ return err
80128012+ }
80138013+ if _, err := cw.WriteString(string("references")); err != nil {
80148014+ return err
80158015+ }
80168016+80178017+ if len(t.References) > 8192 {
80188018+ return xerrors.Errorf("Slice value in field t.References was too long")
80198019+ }
80208020+80218021+ if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.References))); err != nil {
80228022+ return err
80238023+ }
80248024+ for _, v := range t.References {
80258025+ if len(v) > 1000000 {
80268026+ return xerrors.Errorf("Value in field v was too long")
80278027+ }
80288028+80298029+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil {
80308030+ return err
80318031+ }
80328032+ if _, err := cw.WriteString(string(v)); err != nil {
80338033+ return err
80348034+ }
80358035+80368036+ }
80378037+ }
80388038+ return nil
80398039+}
80408040+80418041+func (t *RepoDiscussionComment) UnmarshalCBOR(r io.Reader) (err error) {
80428042+ *t = RepoDiscussionComment{}
80438043+80448044+ cr := cbg.NewCborReader(r)
80458045+80468046+ maj, extra, err := cr.ReadHeader()
80478047+ if err != nil {
80488048+ return err
80498049+ }
80508050+ defer func() {
80518051+ if err == io.EOF {
80528052+ err = io.ErrUnexpectedEOF
80538053+ }
80548054+ }()
80558055+80568056+ if maj != cbg.MajMap {
80578057+ return fmt.Errorf("cbor input should be of type map")
80588058+ }
80598059+80608060+ if extra > cbg.MaxLength {
80618061+ return fmt.Errorf("RepoDiscussionComment: map struct too large (%d)", extra)
80628062+ }
80638063+80648064+ n := extra
80658065+80668066+ nameBuf := make([]byte, 10)
80678067+ for i := uint64(0); i < n; i++ {
80688068+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
80698069+ if err != nil {
80708070+ return err
80718071+ }
80728072+80738073+ if !ok {
80748074+ // Field doesn't exist on this type, so ignore it
80758075+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
80768076+ return err
80778077+ }
80788078+ continue
80798079+ }
80808080+80818081+ switch string(nameBuf[:nameLen]) {
80828082+ // t.Body (string) (string)
80838083+ case "body":
80848084+80858085+ {
80868086+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
80878087+ if err != nil {
80888088+ return err
80898089+ }
80908090+80918091+ t.Body = string(sval)
80928092+ }
80938093+ // t.LexiconTypeID (string) (string)
80948094+ case "$type":
80958095+80968096+ {
80978097+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
80988098+ if err != nil {
80998099+ return err
81008100+ }
81018101+81028102+ t.LexiconTypeID = string(sval)
81038103+ }
81048104+ // t.ReplyTo (string) (string)
81058105+ case "replyTo":
81068106+81078107+ {
81088108+ b, err := cr.ReadByte()
81098109+ if err != nil {
81108110+ return err
81118111+ }
81128112+ if b != cbg.CborNull[0] {
81138113+ if err := cr.UnreadByte(); err != nil {
81148114+ return err
81158115+ }
81168116+81178117+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
81188118+ if err != nil {
81198119+ return err
81208120+ }
81218121+81228122+ t.ReplyTo = (*string)(&sval)
81238123+ }
81248124+ }
81258125+ // t.Mentions ([]string) (slice)
81268126+ case "mentions":
81278127+81288128+ maj, extra, err = cr.ReadHeader()
81298129+ if err != nil {
81308130+ return err
81318131+ }
81328132+81338133+ if extra > 8192 {
81348134+ return fmt.Errorf("t.Mentions: array too large (%d)", extra)
81358135+ }
81368136+81378137+ if maj != cbg.MajArray {
81388138+ return fmt.Errorf("expected cbor array")
81398139+ }
81408140+81418141+ if extra > 0 {
81428142+ t.Mentions = make([]string, extra)
81438143+ }
81448144+81458145+ for i := 0; i < int(extra); i++ {
81468146+ {
81478147+ var maj byte
81488148+ var extra uint64
81498149+ var err error
81508150+ _ = maj
81518151+ _ = extra
81528152+ _ = err
81538153+81548154+ {
81558155+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
81568156+ if err != nil {
81578157+ return err
81588158+ }
81598159+81608160+ t.Mentions[i] = string(sval)
81618161+ }
81628162+81638163+ }
81648164+ }
81658165+ // t.CreatedAt (string) (string)
81668166+ case "createdAt":
81678167+81688168+ {
81698169+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
81708170+ if err != nil {
81718171+ return err
81728172+ }
81738173+81748174+ t.CreatedAt = string(sval)
81758175+ }
81768176+ // t.Discussion (string) (string)
81778177+ case "discussion":
81788178+81798179+ {
81808180+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
81818181+ if err != nil {
81828182+ return err
81838183+ }
81848184+81858185+ t.Discussion = string(sval)
81868186+ }
81878187+ // t.References ([]string) (slice)
81888188+ case "references":
81898189+81908190+ maj, extra, err = cr.ReadHeader()
81918191+ if err != nil {
81928192+ return err
81938193+ }
81948194+81958195+ if extra > 8192 {
81968196+ return fmt.Errorf("t.References: array too large (%d)", extra)
81978197+ }
81988198+81998199+ if maj != cbg.MajArray {
82008200+ return fmt.Errorf("expected cbor array")
82018201+ }
82028202+82038203+ if extra > 0 {
82048204+ t.References = make([]string, extra)
82058205+ }
82068206+82078207+ for i := 0; i < int(extra); i++ {
82088208+ {
82098209+ var maj byte
82108210+ var extra uint64
82118211+ var err error
82128212+ _ = maj
82138213+ _ = extra
82148214+ _ = err
82158215+82168216+ {
82178217+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
82188218+ if err != nil {
82198219+ return err
82208220+ }
82218221+82228222+ t.References[i] = string(sval)
82238223+ }
82248224+82258225+ }
82268226+ }
82278227+82288228+ default:
82298229+ // Field doesn't exist on this type, so ignore it
82308230+ if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
82318231+ return err
82328232+ }
82338233+ }
82348234+ }
82358235+82368236+ return nil
82378237+}
82388238+func (t *RepoDiscussionState) MarshalCBOR(w io.Writer) error {
82398239+ if t == nil {
82408240+ _, err := w.Write(cbg.CborNull)
82418241+ return err
82428242+ }
82438243+82448244+ cw := cbg.NewCborWriter(w)
82458245+82468246+ if _, err := cw.Write([]byte{164}); err != nil {
82478247+ return err
82488248+ }
82498249+82508250+ // t.LexiconTypeID (string) (string)
82518251+ if len("$type") > 1000000 {
82528252+ return xerrors.Errorf("Value in field \"$type\" was too long")
82538253+ }
82548254+82558255+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("$type"))); err != nil {
82568256+ return err
82578257+ }
82588258+ if _, err := cw.WriteString(string("$type")); err != nil {
82598259+ return err
82608260+ }
82618261+82628262+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.discussion.state"))); err != nil {
82638263+ return err
82648264+ }
82658265+ if _, err := cw.WriteString(string("sh.tangled.repo.discussion.state")); err != nil {
82668266+ return err
82678267+ }
82688268+82698269+ // t.State (string) (string)
82708270+ if len("state") > 1000000 {
82718271+ return xerrors.Errorf("Value in field \"state\" was too long")
82728272+ }
82738273+82748274+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil {
82758275+ return err
82768276+ }
82778277+ if _, err := cw.WriteString(string("state")); err != nil {
82788278+ return err
82798279+ }
82808280+82818281+ if len(t.State) > 1000000 {
82828282+ return xerrors.Errorf("Value in field t.State was too long")
82838283+ }
82848284+82858285+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.State))); err != nil {
82868286+ return err
82878287+ }
82888288+ if _, err := cw.WriteString(string(t.State)); err != nil {
82898289+ return err
82908290+ }
82918291+82928292+ // t.CreatedAt (string) (string)
82938293+ if len("createdAt") > 1000000 {
82948294+ return xerrors.Errorf("Value in field \"createdAt\" was too long")
82958295+ }
82968296+82978297+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("createdAt"))); err != nil {
82988298+ return err
82998299+ }
83008300+ if _, err := cw.WriteString(string("createdAt")); err != nil {
83018301+ return err
83028302+ }
83038303+83048304+ if len(t.CreatedAt) > 1000000 {
83058305+ return xerrors.Errorf("Value in field t.CreatedAt was too long")
83068306+ }
83078307+83088308+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.CreatedAt))); err != nil {
83098309+ return err
83108310+ }
83118311+ if _, err := cw.WriteString(string(t.CreatedAt)); err != nil {
83128312+ return err
83138313+ }
83148314+83158315+ // t.Discussion (string) (string)
83168316+ if len("discussion") > 1000000 {
83178317+ return xerrors.Errorf("Value in field \"discussion\" was too long")
83188318+ }
83198319+83208320+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("discussion"))); err != nil {
83218321+ return err
83228322+ }
83238323+ if _, err := cw.WriteString(string("discussion")); err != nil {
83248324+ return err
83258325+ }
83268326+83278327+ if len(t.Discussion) > 1000000 {
83288328+ return xerrors.Errorf("Value in field t.Discussion was too long")
83298329+ }
83308330+83318331+ if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Discussion))); err != nil {
83328332+ return err
83338333+ }
83348334+ if _, err := cw.WriteString(string(t.Discussion)); err != nil {
83358335+ return err
83368336+ }
83378337+ return nil
83388338+}
83398339+83408340+func (t *RepoDiscussionState) UnmarshalCBOR(r io.Reader) (err error) {
83418341+ *t = RepoDiscussionState{}
83428342+83438343+ cr := cbg.NewCborReader(r)
83448344+83458345+ maj, extra, err := cr.ReadHeader()
83468346+ if err != nil {
83478347+ return err
83488348+ }
83498349+ defer func() {
83508350+ if err == io.EOF {
83518351+ err = io.ErrUnexpectedEOF
83528352+ }
83538353+ }()
83548354+83558355+ if maj != cbg.MajMap {
83568356+ return fmt.Errorf("cbor input should be of type map")
83578357+ }
83588358+83598359+ if extra > cbg.MaxLength {
83608360+ return fmt.Errorf("RepoDiscussionState: map struct too large (%d)", extra)
83618361+ }
83628362+83638363+ n := extra
83648364+83658365+ nameBuf := make([]byte, 10)
83668366+ for i := uint64(0); i < n; i++ {
83678367+ nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
83688368+ if err != nil {
83698369+ return err
83708370+ }
83718371+83728372+ if !ok {
83738373+ // Field doesn't exist on this type, so ignore it
83748374+ if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
83758375+ return err
83768376+ }
83778377+ continue
83788378+ }
83798379+83808380+ switch string(nameBuf[:nameLen]) {
83818381+ // t.LexiconTypeID (string) (string)
83828382+ case "$type":
83838383+83848384+ {
83858385+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83868386+ if err != nil {
83878387+ return err
83888388+ }
83898389+83908390+ t.LexiconTypeID = string(sval)
83918391+ }
83928392+ // t.State (string) (string)
83938393+ case "state":
83948394+83958395+ {
83968396+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
83978397+ if err != nil {
83988398+ return err
83998399+ }
84008400+84018401+ t.State = string(sval)
84028402+ }
84038403+ // t.CreatedAt (string) (string)
84048404+ case "createdAt":
84058405+84068406+ {
84078407+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
84088408+ if err != nil {
84098409+ return err
84108410+ }
84118411+84128412+ t.CreatedAt = string(sval)
84138413+ }
84148414+ // t.Discussion (string) (string)
84158415+ case "discussion":
84168416+84178417+ {
84188418+ sval, err := cbg.ReadStringWithMax(cr, 1000000)
84198419+ if err != nil {
84208420+ return err
84218421+ }
84228422+84238423+ t.Discussion = string(sval)
69658424 }
6966842569678426 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+}
+79
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: List of change hashes that were applied
2828+ Changes []string `json:"changes" cborgen:"changes"`
2929+ // channel: Channel that was updated
3030+ Channel string `json:"channel" cborgen:"channel"`
3131+ // languages: Map of language name to lines of code
3232+ Languages *PijulRefUpdate_Languages `json:"languages,omitempty" cborgen:"languages,omitempty"`
3333+ // newState: New Merkle hash after update
3434+ NewState string `json:"newState" cborgen:"newState"`
3535+ // oldState: Previous Merkle hash (empty for new channels)
3636+ OldState *string `json:"oldState,omitempty" cborgen:"oldState,omitempty"`
3737+ // repo: Repository identifier
3838+ Repo string `json:"repo" cborgen:"repo"`
3939+}
4040+4141+// Map of language name to lines of code
4242+type PijulRefUpdate_Languages struct {
4343+}
4444+4545+func (t *PijulRefUpdate_Languages) MarshalCBOR(w io.Writer) error {
4646+ if t == nil {
4747+ _, err := w.Write(cbg.CborNull)
4848+ return err
4949+ }
5050+ cw := cbg.NewCborWriter(w)
5151+ if err := cw.WriteMajorTypeHeader(cbg.MajMap, 0); err != nil {
5252+ return err
5353+ }
5454+ return nil
5555+}
5656+5757+func (t *PijulRefUpdate_Languages) UnmarshalCBOR(r io.Reader) error {
5858+ *t = PijulRefUpdate_Languages{}
5959+ cr := cbg.NewCborReader(r)
6060+ maj, extra, err := cr.ReadHeader()
6161+ if err != nil {
6262+ return err
6363+ }
6464+ if maj != cbg.MajMap {
6565+ return fmt.Errorf("expected cbor map for PijulRefUpdate_Languages")
6666+ }
6767+ // skip all entries
6868+ for i := uint64(0); i < extra; i++ {
6969+ // skip key
7070+ if err := cbg.ScanForLinks(cr, func(_ cid.Cid) {}); err != nil {
7171+ return err
7272+ }
7373+ // skip value
7474+ if err := cbg.ScanForLinks(cr, func(_ cid.Cid) {}); err != nil {
7575+ return err
7676+ }
7777+ }
7878+ return nil
7979+}
+48
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+}
3434+3535+type RepoApplyChanges_Output_Failed_Elem struct {
3636+ Error string `json:"error" cborgen:"error"`
3737+ Hash string `json:"hash" cborgen:"hash"`
3838+}
3939+4040+// RepoApplyChanges calls the XRPC method "sh.tangled.repo.applyChanges".
4141+func RepoApplyChanges(ctx context.Context, c util.LexClient, input *RepoApplyChanges_Input) (*RepoApplyChanges_Output, error) {
4242+ var out RepoApplyChanges_Output
4343+ if err := c.LexDo(ctx, util.Procedure, "application/json", "sh.tangled.repo.applyChanges", nil, input, &out); err != nil {
4444+ return nil, err
4545+ }
4646+4747+ return &out, nil
4848+}
+53
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+ Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
2020+ Name string `json:"name" cborgen:"name"`
2121+}
2222+2323+// RepoChangeGet_Output is the output of a sh.tangled.repo.changeGet call.
2424+type RepoChangeGet_Output struct {
2525+ Authors []*RepoChangeGet_Author `json:"authors" cborgen:"authors"`
2626+ // dependencies: Hashes of changes this change depends on
2727+ Dependencies []string `json:"dependencies,omitempty" cborgen:"dependencies,omitempty"`
2828+ // diff: Raw diff content of the change
2929+ Diff *string `json:"diff,omitempty" cborgen:"diff,omitempty"`
3030+ // hash: Change hash (base32 encoded)
3131+ Hash string `json:"hash" cborgen:"hash"`
3232+ // message: Change description
3333+ Message string `json:"message" cborgen:"message"`
3434+ // timestamp: When the change was recorded
3535+ Timestamp *string `json:"timestamp,omitempty" cborgen:"timestamp,omitempty"`
3636+}
3737+3838+// RepoChangeGet calls the XRPC method "sh.tangled.repo.changeGet".
3939+//
4040+// hash: Change hash to retrieve
4141+// repo: Repository identifier in format 'did:plc:.../repoName'
4242+func RepoChangeGet(ctx context.Context, c util.LexClient, hash string, repo string) (*RepoChangeGet_Output, error) {
4343+ var out RepoChangeGet_Output
4444+4545+ params := map[string]interface{}{}
4646+ params["hash"] = hash
4747+ params["repo"] = repo
4848+ if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.changeGet", params, nil, &out); err != nil {
4949+ return nil, err
5050+ }
5151+5252+ return &out, nil
5353+}
+70
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+ Email *string `json:"email,omitempty" cborgen:"email,omitempty"`
2020+ Name string `json:"name" cborgen:"name"`
2121+}
2222+2323+// RepoChangeList_ChangeEntry is a "changeEntry" in the sh.tangled.repo.changeList schema.
2424+type RepoChangeList_ChangeEntry struct {
2525+ Authors []*RepoChangeList_Author `json:"authors" cborgen:"authors"`
2626+ // dependencies: Hashes of changes this change depends on
2727+ Dependencies []string `json:"dependencies,omitempty" cborgen:"dependencies,omitempty"`
2828+ // hash: Change hash (base32 encoded)
2929+ Hash string `json:"hash" cborgen:"hash"`
3030+ // message: Change description
3131+ Message string `json:"message" cborgen:"message"`
3232+ // timestamp: When the change was recorded
3333+ Timestamp *string `json:"timestamp,omitempty" cborgen:"timestamp,omitempty"`
3434+}
3535+3636+// RepoChangeList_Output is the output of a sh.tangled.repo.changeList call.
3737+type RepoChangeList_Output struct {
3838+ Changes []*RepoChangeList_ChangeEntry `json:"changes" cborgen:"changes"`
3939+ Channel *string `json:"channel,omitempty" cborgen:"channel,omitempty"`
4040+ Page int64 `json:"page" cborgen:"page"`
4141+ Per_page int64 `json:"per_page" cborgen:"per_page"`
4242+ Total int64 `json:"total" cborgen:"total"`
4343+}
4444+4545+// RepoChangeList calls the XRPC method "sh.tangled.repo.changeList".
4646+//
4747+// channel: Pijul channel name (defaults to main channel)
4848+// cursor: Pagination cursor (offset)
4949+// limit: Maximum number of changes to return
5050+// repo: Repository identifier in format 'did:plc:.../repoName'
5151+func RepoChangeList(ctx context.Context, c util.LexClient, channel string, cursor string, limit int64, repo string) (*RepoChangeList_Output, error) {
5252+ var out RepoChangeList_Output
5353+5454+ params := map[string]interface{}{}
5555+ if channel != "" {
5656+ params["channel"] = channel
5757+ }
5858+ if cursor != "" {
5959+ params["cursor"] = cursor
6060+ }
6161+ if limit != 0 {
6262+ params["limit"] = limit
6363+ }
6464+ params["repo"] = repo
6565+ if err := c.LexDo(ctx, util.Query, "", "sh.tangled.repo.changeList", params, nil, &out); err != nil {
6666+ return nil, err
6767+ }
6868+6969+ return &out, nil
7070+}
+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
···2222 Rkey string `json:"rkey" cborgen:"rkey"`
2323 // source: A source URL to clone from, populate this when forking or importing a repository.
2424 Source *string `json:"source,omitempty" cborgen:"source,omitempty"`
2525+ // vcs: Version control system to use for the repository (git or pijul).
2626+ Vcs *string `json:"vcs,omitempty" cborgen:"vcs,omitempty"`
2527}
26282729// RepoCreate calls the XRPC method "sh.tangled.repo.create".
···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-
···11+package pijul
22+33+import (
44+ "context"
55+ "fmt"
66+ "io/fs"
77+ "os"
88+ "path"
99+ "path/filepath"
1010+ "strings"
1111+1212+ securejoin "github.com/cyphar/filepath-securejoin"
1313+ "tangled.org/core/types"
1414+)
1515+1616+// TreeEntry represents a file or directory in the repository tree
1717+type TreeEntry struct {
1818+ Name string `json:"name"`
1919+ Mode fs.FileMode `json:"mode"`
2020+ Size int64 `json:"size"`
2121+ IsDir bool `json:"is_dir"`
2222+}
2323+2424+// FileTree returns the file tree at the given path
2525+// For Pijul, we read directly from the working directory
2626+func (p *PijulRepo) FileTree(ctx context.Context, treePath string) ([]types.NiceTree, error) {
2727+ fullPath, err := securejoin.SecureJoin(p.path, treePath)
2828+ if err != nil {
2929+ return nil, fmt.Errorf("invalid path: %w", err)
3030+ }
3131+3232+ info, err := os.Stat(fullPath)
3333+ if err != nil {
3434+ if os.IsNotExist(err) {
3535+ return nil, ErrPathNotFound
3636+ }
3737+ return nil, err
3838+ }
3939+4040+ // If it's a file, return empty (no tree for files)
4141+ if !info.IsDir() {
4242+ return []types.NiceTree{}, nil
4343+ }
4444+4545+ entries, err := os.ReadDir(fullPath)
4646+ if err != nil {
4747+ return nil, err
4848+ }
4949+5050+ trees := make([]types.NiceTree, 0, len(entries))
5151+5252+ for _, entry := range entries {
5353+ // Skip .pijul directory
5454+ if entry.Name() == ".pijul" {
5555+ continue
5656+ }
5757+5858+ info, err := entry.Info()
5959+ if err != nil {
6060+ continue
6161+ }
6262+6363+ trees = append(trees, types.NiceTree{
6464+ Name: entry.Name(),
6565+ Mode: fileModeToString(info.Mode()),
6666+ Size: info.Size(),
6767+ // LastCommit would require additional work to implement
6868+ // For now, we leave it nil
6969+ })
7070+ }
7171+7272+ return trees, nil
7373+}
7474+7575+// fileModeToString converts fs.FileMode to octal string representation
7676+func fileModeToString(mode fs.FileMode) string {
7777+ // Convert to git-style mode representation
7878+ if mode.IsDir() {
7979+ return "040000"
8080+ }
8181+ if mode&fs.ModeSymlink != 0 {
8282+ return "120000"
8383+ }
8484+ if mode&0111 != 0 {
8585+ return "100755"
8686+ }
8787+ return "100644"
8888+}
8989+9090+// Walk callback type
9191+type WalkCallback func(path string, info fs.FileInfo, isDir bool) error
9292+9393+// Walk traverses the file tree
9494+func (p *PijulRepo) Walk(ctx context.Context, root string, cb WalkCallback) error {
9595+ startPath, err := securejoin.SecureJoin(p.path, root)
9696+ if err != nil {
9797+ return fmt.Errorf("invalid path: %w", err)
9898+ }
9999+100100+ return filepath.WalkDir(startPath, func(walkPath string, d fs.DirEntry, err error) error {
101101+ if err != nil {
102102+ return err
103103+ }
104104+105105+ // Check context
106106+ select {
107107+ case <-ctx.Done():
108108+ return ctx.Err()
109109+ default:
110110+ }
111111+112112+ // Skip .pijul directory
113113+ if d.IsDir() && filepath.Base(walkPath) == ".pijul" {
114114+ return filepath.SkipDir
115115+ }
116116+117117+ // Get relative path
118118+ relPath, err := filepath.Rel(p.path, walkPath)
119119+ if err != nil {
120120+ return err
121121+ }
122122+123123+ if relPath == "." {
124124+ return nil
125125+ }
126126+127127+ info, err := d.Info()
128128+ if err != nil {
129129+ return err
130130+ }
131131+132132+ return cb(relPath, info, d.IsDir())
133133+ })
134134+}
135135+136136+// ListFiles returns all tracked files in the repository
137137+func (p *PijulRepo) ListFiles() ([]string, error) {
138138+ output, err := p.runPijulCmd("ls")
139139+ if err != nil {
140140+ return nil, err
141141+ }
142142+143143+ lines := strings.Split(strings.TrimSpace(string(output)), "\n")
144144+ if len(lines) == 1 && lines[0] == "" {
145145+ return []string{}, nil
146146+ }
147147+148148+ return lines, nil
149149+}
150150+151151+// IsTracked checks if a file is tracked by Pijul
152152+func (p *PijulRepo) IsTracked(filePath string) (bool, error) {
153153+ files, err := p.ListFiles()
154154+ if err != nil {
155155+ return false, err
156156+ }
157157+158158+ for _, f := range files {
159159+ if f == filePath {
160160+ return true, nil
161161+ }
162162+ }
163163+164164+ return false, nil
165165+}
166166+167167+// FileExists checks if a file exists in the working directory
168168+func (p *PijulRepo) FileExists(filePath string) bool {
169169+ fullPath, err := securejoin.SecureJoin(p.path, filePath)
170170+ if err != nil {
171171+ return false
172172+ }
173173+ _, err = os.Stat(fullPath)
174174+ return err == nil
175175+}
176176+177177+// IsDir checks if a path is a directory
178178+func (p *PijulRepo) IsDir(treePath string) (bool, error) {
179179+ fullPath, err := securejoin.SecureJoin(p.path, treePath)
180180+ if err != nil {
181181+ return false, fmt.Errorf("invalid path: %w", err)
182182+ }
183183+ info, err := os.Stat(fullPath)
184184+ if err != nil {
185185+ return false, err
186186+ }
187187+ return info.IsDir(), nil
188188+}
189189+190190+// MakeNiceTree creates a NiceTree from file info
191191+func MakeNiceTree(name string, info fs.FileInfo) types.NiceTree {
192192+ return types.NiceTree{
193193+ Name: path.Base(name),
194194+ Mode: fileModeToString(info.Mode()),
195195+ Size: info.Size(),
196196+ }
197197+}
+75
knotserver/vcs/backend.go
···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+}
···2424 "source": {
2525 "type": "string",
2626 "description": "A source URL to clone from, populate this when forking or importing a repository."
2727+ },
2828+ "vcs": {
2929+ "type": "string",
3030+ "description": "Version control system to use for the repository (git or pijul)."
2731 }
2832 }
2933 }