Signed-off-by: oppiliappan me@oppi.li
+344
-2
api/tangled/cbor_gen.go
+344
-2
api/tangled/cbor_gen.go
···
1209
}
1210
1211
cw := cbg.NewCborWriter(w)
1212
1213
-
if _, err := cw.Write([]byte{162}); err != nil {
1214
return err
1215
}
1216
···
1245
if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil {
1246
return err
1247
}
1248
return nil
1249
}
1250
···
1273
1274
n := extra
1275
1276
-
nameBuf := make([]byte, 12)
1277
for i := uint64(0); i < n; i++ {
1278
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1279
if err != nil {
···
1327
default:
1328
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
1329
}
1330
1331
default:
1332
// Field doesn't exist on this type, so ignore it
···
1635
1636
return nil
1637
}
1638
func (t *GraphFollow) MarshalCBOR(w io.Writer) error {
1639
if t == nil {
1640
_, err := w.Write(cbg.CborNull)
···
1209
}
1210
1211
cw := cbg.NewCborWriter(w)
1212
+
fieldCount := 3
1213
1214
+
if t.LangBreakdown == nil {
1215
+
fieldCount--
1216
+
}
1217
+
1218
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
1219
return err
1220
}
1221
···
1250
if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil {
1251
return err
1252
}
1253
+
1254
+
// t.LangBreakdown (tangled.GitRefUpdate_Meta_LangBreakdown) (struct)
1255
+
if t.LangBreakdown != nil {
1256
+
1257
+
if len("langBreakdown") > 1000000 {
1258
+
return xerrors.Errorf("Value in field \"langBreakdown\" was too long")
1259
+
}
1260
+
1261
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("langBreakdown"))); err != nil {
1262
+
return err
1263
+
}
1264
+
if _, err := cw.WriteString(string("langBreakdown")); err != nil {
1265
+
return err
1266
+
}
1267
+
1268
+
if err := t.LangBreakdown.MarshalCBOR(cw); err != nil {
1269
+
return err
1270
+
}
1271
+
}
1272
return nil
1273
}
1274
···
1297
1298
n := extra
1299
1300
+
nameBuf := make([]byte, 13)
1301
for i := uint64(0); i < n; i++ {
1302
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1303
if err != nil {
···
1351
default:
1352
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
1353
}
1354
+
// t.LangBreakdown (tangled.GitRefUpdate_Meta_LangBreakdown) (struct)
1355
+
case "langBreakdown":
1356
+
1357
+
{
1358
+
1359
+
b, err := cr.ReadByte()
1360
+
if err != nil {
1361
+
return err
1362
+
}
1363
+
if b != cbg.CborNull[0] {
1364
+
if err := cr.UnreadByte(); err != nil {
1365
+
return err
1366
+
}
1367
+
t.LangBreakdown = new(GitRefUpdate_Meta_LangBreakdown)
1368
+
if err := t.LangBreakdown.UnmarshalCBOR(cr); err != nil {
1369
+
return xerrors.Errorf("unmarshaling t.LangBreakdown pointer: %w", err)
1370
+
}
1371
+
}
1372
+
1373
+
}
1374
1375
default:
1376
// Field doesn't exist on this type, so ignore it
···
1679
1680
return nil
1681
}
1682
+
func (t *GitRefUpdate_Meta_LangBreakdown) MarshalCBOR(w io.Writer) error {
1683
+
if t == nil {
1684
+
_, err := w.Write(cbg.CborNull)
1685
+
return err
1686
+
}
1687
+
1688
+
cw := cbg.NewCborWriter(w)
1689
+
fieldCount := 1
1690
+
1691
+
if t.Inputs == nil {
1692
+
fieldCount--
1693
+
}
1694
+
1695
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
1696
+
return err
1697
+
}
1698
+
1699
+
// t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice)
1700
+
if t.Inputs != nil {
1701
+
1702
+
if len("inputs") > 1000000 {
1703
+
return xerrors.Errorf("Value in field \"inputs\" was too long")
1704
+
}
1705
+
1706
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("inputs"))); err != nil {
1707
+
return err
1708
+
}
1709
+
if _, err := cw.WriteString(string("inputs")); err != nil {
1710
+
return err
1711
+
}
1712
+
1713
+
if len(t.Inputs) > 8192 {
1714
+
return xerrors.Errorf("Slice value in field t.Inputs was too long")
1715
+
}
1716
+
1717
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Inputs))); err != nil {
1718
+
return err
1719
+
}
1720
+
for _, v := range t.Inputs {
1721
+
if err := v.MarshalCBOR(cw); err != nil {
1722
+
return err
1723
+
}
1724
+
1725
+
}
1726
+
}
1727
+
return nil
1728
+
}
1729
+
1730
+
func (t *GitRefUpdate_Meta_LangBreakdown) UnmarshalCBOR(r io.Reader) (err error) {
1731
+
*t = GitRefUpdate_Meta_LangBreakdown{}
1732
+
1733
+
cr := cbg.NewCborReader(r)
1734
+
1735
+
maj, extra, err := cr.ReadHeader()
1736
+
if err != nil {
1737
+
return err
1738
+
}
1739
+
defer func() {
1740
+
if err == io.EOF {
1741
+
err = io.ErrUnexpectedEOF
1742
+
}
1743
+
}()
1744
+
1745
+
if maj != cbg.MajMap {
1746
+
return fmt.Errorf("cbor input should be of type map")
1747
+
}
1748
+
1749
+
if extra > cbg.MaxLength {
1750
+
return fmt.Errorf("GitRefUpdate_Meta_LangBreakdown: map struct too large (%d)", extra)
1751
+
}
1752
+
1753
+
n := extra
1754
+
1755
+
nameBuf := make([]byte, 6)
1756
+
for i := uint64(0); i < n; i++ {
1757
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1758
+
if err != nil {
1759
+
return err
1760
+
}
1761
+
1762
+
if !ok {
1763
+
// Field doesn't exist on this type, so ignore it
1764
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1765
+
return err
1766
+
}
1767
+
continue
1768
+
}
1769
+
1770
+
switch string(nameBuf[:nameLen]) {
1771
+
// t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice)
1772
+
case "inputs":
1773
+
1774
+
maj, extra, err = cr.ReadHeader()
1775
+
if err != nil {
1776
+
return err
1777
+
}
1778
+
1779
+
if extra > 8192 {
1780
+
return fmt.Errorf("t.Inputs: array too large (%d)", extra)
1781
+
}
1782
+
1783
+
if maj != cbg.MajArray {
1784
+
return fmt.Errorf("expected cbor array")
1785
+
}
1786
+
1787
+
if extra > 0 {
1788
+
t.Inputs = make([]*GitRefUpdate_Pair, extra)
1789
+
}
1790
+
1791
+
for i := 0; i < int(extra); i++ {
1792
+
{
1793
+
var maj byte
1794
+
var extra uint64
1795
+
var err error
1796
+
_ = maj
1797
+
_ = extra
1798
+
_ = err
1799
+
1800
+
{
1801
+
1802
+
b, err := cr.ReadByte()
1803
+
if err != nil {
1804
+
return err
1805
+
}
1806
+
if b != cbg.CborNull[0] {
1807
+
if err := cr.UnreadByte(); err != nil {
1808
+
return err
1809
+
}
1810
+
t.Inputs[i] = new(GitRefUpdate_Pair)
1811
+
if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil {
1812
+
return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err)
1813
+
}
1814
+
}
1815
+
1816
+
}
1817
+
1818
+
}
1819
+
}
1820
+
1821
+
default:
1822
+
// Field doesn't exist on this type, so ignore it
1823
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1824
+
return err
1825
+
}
1826
+
}
1827
+
}
1828
+
1829
+
return nil
1830
+
}
1831
+
func (t *GitRefUpdate_Pair) MarshalCBOR(w io.Writer) error {
1832
+
if t == nil {
1833
+
_, err := w.Write(cbg.CborNull)
1834
+
return err
1835
+
}
1836
+
1837
+
cw := cbg.NewCborWriter(w)
1838
+
1839
+
if _, err := cw.Write([]byte{162}); err != nil {
1840
+
return err
1841
+
}
1842
+
1843
+
// t.Lang (string) (string)
1844
+
if len("lang") > 1000000 {
1845
+
return xerrors.Errorf("Value in field \"lang\" was too long")
1846
+
}
1847
+
1848
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("lang"))); err != nil {
1849
+
return err
1850
+
}
1851
+
if _, err := cw.WriteString(string("lang")); err != nil {
1852
+
return err
1853
+
}
1854
+
1855
+
if len(t.Lang) > 1000000 {
1856
+
return xerrors.Errorf("Value in field t.Lang was too long")
1857
+
}
1858
+
1859
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Lang))); err != nil {
1860
+
return err
1861
+
}
1862
+
if _, err := cw.WriteString(string(t.Lang)); err != nil {
1863
+
return err
1864
+
}
1865
+
1866
+
// t.Size (int64) (int64)
1867
+
if len("size") > 1000000 {
1868
+
return xerrors.Errorf("Value in field \"size\" was too long")
1869
+
}
1870
+
1871
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("size"))); err != nil {
1872
+
return err
1873
+
}
1874
+
if _, err := cw.WriteString(string("size")); err != nil {
1875
+
return err
1876
+
}
1877
+
1878
+
if t.Size >= 0 {
1879
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Size)); err != nil {
1880
+
return err
1881
+
}
1882
+
} else {
1883
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Size-1)); err != nil {
1884
+
return err
1885
+
}
1886
+
}
1887
+
1888
+
return nil
1889
+
}
1890
+
1891
+
func (t *GitRefUpdate_Pair) UnmarshalCBOR(r io.Reader) (err error) {
1892
+
*t = GitRefUpdate_Pair{}
1893
+
1894
+
cr := cbg.NewCborReader(r)
1895
+
1896
+
maj, extra, err := cr.ReadHeader()
1897
+
if err != nil {
1898
+
return err
1899
+
}
1900
+
defer func() {
1901
+
if err == io.EOF {
1902
+
err = io.ErrUnexpectedEOF
1903
+
}
1904
+
}()
1905
+
1906
+
if maj != cbg.MajMap {
1907
+
return fmt.Errorf("cbor input should be of type map")
1908
+
}
1909
+
1910
+
if extra > cbg.MaxLength {
1911
+
return fmt.Errorf("GitRefUpdate_Pair: map struct too large (%d)", extra)
1912
+
}
1913
+
1914
+
n := extra
1915
+
1916
+
nameBuf := make([]byte, 4)
1917
+
for i := uint64(0); i < n; i++ {
1918
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1919
+
if err != nil {
1920
+
return err
1921
+
}
1922
+
1923
+
if !ok {
1924
+
// Field doesn't exist on this type, so ignore it
1925
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1926
+
return err
1927
+
}
1928
+
continue
1929
+
}
1930
+
1931
+
switch string(nameBuf[:nameLen]) {
1932
+
// t.Lang (string) (string)
1933
+
case "lang":
1934
+
1935
+
{
1936
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1937
+
if err != nil {
1938
+
return err
1939
+
}
1940
+
1941
+
t.Lang = string(sval)
1942
+
}
1943
+
// t.Size (int64) (int64)
1944
+
case "size":
1945
+
{
1946
+
maj, extra, err := cr.ReadHeader()
1947
+
if err != nil {
1948
+
return err
1949
+
}
1950
+
var extraI int64
1951
+
switch maj {
1952
+
case cbg.MajUnsignedInt:
1953
+
extraI = int64(extra)
1954
+
if extraI < 0 {
1955
+
return fmt.Errorf("int64 positive overflow")
1956
+
}
1957
+
case cbg.MajNegativeInt:
1958
+
extraI = int64(extra)
1959
+
if extraI < 0 {
1960
+
return fmt.Errorf("int64 negative overflow")
1961
+
}
1962
+
extraI = -1 - extraI
1963
+
default:
1964
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
1965
+
}
1966
+
1967
+
t.Size = int64(extraI)
1968
+
}
1969
+
1970
+
default:
1971
+
// Field doesn't exist on this type, so ignore it
1972
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1973
+
return err
1974
+
}
1975
+
}
1976
+
}
1977
+
1978
+
return nil
1979
+
}
1980
func (t *GraphFollow) MarshalCBOR(w io.Writer) error {
1981
if t == nil {
1982
_, err := w.Write(cbg.CborNull)
+13
-2
api/tangled/gitrefUpdate.go
+13
-2
api/tangled/gitrefUpdate.go
···
34
}
35
36
type GitRefUpdate_Meta struct {
37
-
CommitCount *GitRefUpdate_Meta_CommitCount `json:"commitCount" cborgen:"commitCount"`
38
-
IsDefaultRef bool `json:"isDefaultRef" cborgen:"isDefaultRef"`
39
}
40
41
type GitRefUpdate_Meta_CommitCount struct {
···
46
Count int64 `json:"count" cborgen:"count"`
47
Email string `json:"email" cborgen:"email"`
48
}
···
34
}
35
36
type GitRefUpdate_Meta struct {
37
+
CommitCount *GitRefUpdate_Meta_CommitCount `json:"commitCount" cborgen:"commitCount"`
38
+
IsDefaultRef bool `json:"isDefaultRef" cborgen:"isDefaultRef"`
39
+
LangBreakdown *GitRefUpdate_Meta_LangBreakdown `json:"langBreakdown,omitempty" cborgen:"langBreakdown,omitempty"`
40
}
41
42
type GitRefUpdate_Meta_CommitCount struct {
···
47
Count int64 `json:"count" cborgen:"count"`
48
Email string `json:"email" cborgen:"email"`
49
}
50
+
51
+
type GitRefUpdate_Meta_LangBreakdown struct {
52
+
Inputs []*GitRefUpdate_Pair `json:"inputs,omitempty" cborgen:"inputs,omitempty"`
53
+
}
54
+
55
+
// GitRefUpdate_Pair is a "pair" in the sh.tangled.git.refUpdate schema.
56
+
type GitRefUpdate_Pair struct {
57
+
Lang string `json:"lang" cborgen:"lang"`
58
+
Size int64 `json:"size" cborgen:"size"`
59
+
}
+2
cmd/gen.go
+2
cmd/gen.go
+27
lexicons/git/refUpdate.json
+27
lexicons/git/refUpdate.json
···
61
"type": "boolean",
62
"default": "false"
63
},
64
+
"langBreakdown": {
65
+
"type": "object",
66
+
"properties": {
67
+
"inputs": {
68
+
"type": "array",
69
+
"items": {
70
+
"type": "ref",
71
+
"ref": "#pair"
72
+
}
73
+
}
74
+
}
75
+
},
76
"commitCount": {
77
"type": "object",
78
"required": [],
···
101
}
102
}
103
}
104
+
},
105
+
"pair": {
106
+
"type": "object",
107
+
"required": [
108
+
"lang",
109
+
"size"
110
+
],
111
+
"properties": {
112
+
"lang": {
113
+
"type": "string"
114
+
},
115
+
"size": {
116
+
"type": "integer"
117
+
}
118
+
}
119
}
120
}
121
}