A vibe coded tangled fork which supports pijul.
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3// Lexicon schema: sh.tangled.ci.event
4
5package tangled
6
7import (
8 "bytes"
9 "encoding/json"
10 "fmt"
11 "io"
12
13 lexutil "github.com/bluesky-social/indigo/lex/util"
14 cbg "github.com/whyrusleeping/cbor-gen"
15)
16
17const (
18 CiEventNSID = "sh.tangled.ci.event"
19)
20
21// CiEvent is a "main" in the sh.tangled.ci.event schema.
22type CiEvent struct {
23 Meta *CiEvent_Meta `json:"meta" cborgen:"meta"`
24}
25
26// CiEvent_Manual is a "manual" in the sh.tangled.ci.event schema.
27type CiEvent_Manual struct {
28 LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#manual"`
29}
30
31type CiEvent_Meta struct {
32 CiEvent_PullRequest *CiEvent_PullRequest
33 CiEvent_Push *CiEvent_Push
34 CiEvent_Manual *CiEvent_Manual
35}
36
37func (t *CiEvent_Meta) MarshalJSON() ([]byte, error) {
38 if t.CiEvent_PullRequest != nil {
39 t.CiEvent_PullRequest.LexiconTypeID = "sh.tangled.ci.event#pullRequest"
40 return json.Marshal(t.CiEvent_PullRequest)
41 }
42 if t.CiEvent_Push != nil {
43 t.CiEvent_Push.LexiconTypeID = "sh.tangled.ci.event#push"
44 return json.Marshal(t.CiEvent_Push)
45 }
46 if t.CiEvent_Manual != nil {
47 t.CiEvent_Manual.LexiconTypeID = "sh.tangled.ci.event#manual"
48 return json.Marshal(t.CiEvent_Manual)
49 }
50 return nil, fmt.Errorf("can not marshal empty union as JSON")
51}
52
53func (t *CiEvent_Meta) UnmarshalJSON(b []byte) error {
54 typ, err := lexutil.TypeExtract(b)
55 if err != nil {
56 return err
57 }
58
59 switch typ {
60 case "sh.tangled.ci.event#pullRequest":
61 t.CiEvent_PullRequest = new(CiEvent_PullRequest)
62 return json.Unmarshal(b, t.CiEvent_PullRequest)
63 case "sh.tangled.ci.event#push":
64 t.CiEvent_Push = new(CiEvent_Push)
65 return json.Unmarshal(b, t.CiEvent_Push)
66 case "sh.tangled.ci.event#manual":
67 t.CiEvent_Manual = new(CiEvent_Manual)
68 return json.Unmarshal(b, t.CiEvent_Manual)
69 default:
70 return nil
71 }
72}
73
74func (t *CiEvent_Meta) MarshalCBOR(w io.Writer) error {
75
76 if t == nil {
77 _, err := w.Write(cbg.CborNull)
78 return err
79 }
80 if t.CiEvent_PullRequest != nil {
81 return t.CiEvent_PullRequest.MarshalCBOR(w)
82 }
83 if t.CiEvent_Push != nil {
84 return t.CiEvent_Push.MarshalCBOR(w)
85 }
86 if t.CiEvent_Manual != nil {
87 return t.CiEvent_Manual.MarshalCBOR(w)
88 }
89 return fmt.Errorf("can not marshal empty union as CBOR")
90}
91
92func (t *CiEvent_Meta) UnmarshalCBOR(r io.Reader) error {
93 typ, b, err := lexutil.CborTypeExtractReader(r)
94 if err != nil {
95 return err
96 }
97
98 switch typ {
99 case "sh.tangled.ci.event#pullRequest":
100 t.CiEvent_PullRequest = new(CiEvent_PullRequest)
101 return t.CiEvent_PullRequest.UnmarshalCBOR(bytes.NewReader(b))
102 case "sh.tangled.ci.event#push":
103 t.CiEvent_Push = new(CiEvent_Push)
104 return t.CiEvent_Push.UnmarshalCBOR(bytes.NewReader(b))
105 case "sh.tangled.ci.event#manual":
106 t.CiEvent_Manual = new(CiEvent_Manual)
107 return t.CiEvent_Manual.UnmarshalCBOR(bytes.NewReader(b))
108 default:
109 return nil
110 }
111}
112
113// CiEvent_PullRequest is a "pullRequest" in the sh.tangled.ci.event schema.
114type CiEvent_PullRequest struct {
115 LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#pullRequest"`
116}
117
118// CiEvent_Push is a "push" in the sh.tangled.ci.event schema.
119type CiEvent_Push struct {
120 LexiconTypeID string `json:"$type" cborgen:"$type,const=sh.tangled.ci.event#push"`
121 NewSha string `json:"newSha" cborgen:"newSha"`
122 OldSha string `json:"oldSha" cborgen:"oldSha"`
123 Ref string `json:"ref" cborgen:"ref"`
124}