+955
-486
api/tangled/cbor_gen.go
+955
-486
api/tangled/cbor_gen.go
···
676
677
cw := cbg.NewCborWriter(w)
678
679
-
if _, err := cw.Write([]byte{167}); err != nil {
680
return err
681
}
682
···
700
return err
701
}
702
if _, err := cw.WriteString(string(t.Ref)); err != nil {
703
return err
704
}
705
···
891
892
t.Ref = string(sval)
893
}
894
// t.LexiconTypeID (string) (string)
895
case "$type":
896
···
956
}
957
958
t.CommitterDid = string(sval)
959
}
960
961
default:
···
1719
1720
return nil
1721
}
1722
-
func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error {
1723
-
if t == nil {
1724
-
_, err := w.Write(cbg.CborNull)
1725
-
return err
1726
-
}
1727
-
1728
-
cw := cbg.NewCborWriter(w)
1729
-
1730
-
if _, err := cw.Write([]byte{165}); err != nil {
1731
-
return err
1732
-
}
1733
-
1734
-
// t.Name (string) (string)
1735
-
if len("name") > 1000000 {
1736
-
return xerrors.Errorf("Value in field \"name\" was too long")
1737
-
}
1738
-
1739
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil {
1740
-
return err
1741
-
}
1742
-
if _, err := cw.WriteString(string("name")); err != nil {
1743
-
return err
1744
-
}
1745
-
1746
-
if len(t.Name) > 1000000 {
1747
-
return xerrors.Errorf("Value in field t.Name was too long")
1748
-
}
1749
-
1750
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
1751
-
return err
1752
-
}
1753
-
if _, err := cw.WriteString(string(t.Name)); err != nil {
1754
-
return err
1755
-
}
1756
-
1757
-
// t.Clone (tangled.Pipeline_CloneOpts) (struct)
1758
-
if len("clone") > 1000000 {
1759
-
return xerrors.Errorf("Value in field \"clone\" was too long")
1760
-
}
1761
-
1762
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("clone"))); err != nil {
1763
-
return err
1764
-
}
1765
-
if _, err := cw.WriteString(string("clone")); err != nil {
1766
-
return err
1767
-
}
1768
-
1769
-
if err := t.Clone.MarshalCBOR(cw); err != nil {
1770
-
return err
1771
-
}
1772
-
1773
-
// t.Steps ([]*tangled.Pipeline_Step) (slice)
1774
-
if len("steps") > 1000000 {
1775
-
return xerrors.Errorf("Value in field \"steps\" was too long")
1776
-
}
1777
-
1778
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("steps"))); err != nil {
1779
-
return err
1780
-
}
1781
-
if _, err := cw.WriteString(string("steps")); err != nil {
1782
-
return err
1783
-
}
1784
-
1785
-
if len(t.Steps) > 8192 {
1786
-
return xerrors.Errorf("Slice value in field t.Steps was too long")
1787
-
}
1788
-
1789
-
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Steps))); err != nil {
1790
-
return err
1791
-
}
1792
-
for _, v := range t.Steps {
1793
-
if err := v.MarshalCBOR(cw); err != nil {
1794
-
return err
1795
-
}
1796
-
1797
-
}
1798
-
1799
-
// t.Environment ([]*tangled.Pipeline_Workflow_Environment_Elem) (slice)
1800
-
if len("environment") > 1000000 {
1801
-
return xerrors.Errorf("Value in field \"environment\" was too long")
1802
-
}
1803
-
1804
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("environment"))); err != nil {
1805
-
return err
1806
-
}
1807
-
if _, err := cw.WriteString(string("environment")); err != nil {
1808
-
return err
1809
-
}
1810
-
1811
-
if len(t.Environment) > 8192 {
1812
-
return xerrors.Errorf("Slice value in field t.Environment was too long")
1813
-
}
1814
-
1815
-
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Environment))); err != nil {
1816
-
return err
1817
-
}
1818
-
for _, v := range t.Environment {
1819
-
if err := v.MarshalCBOR(cw); err != nil {
1820
-
return err
1821
-
}
1822
-
1823
-
}
1824
-
1825
-
// t.Dependencies ([]tangled.Pipeline_Dependencies_Elem) (slice)
1826
-
if len("dependencies") > 1000000 {
1827
-
return xerrors.Errorf("Value in field \"dependencies\" was too long")
1828
-
}
1829
-
1830
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("dependencies"))); err != nil {
1831
-
return err
1832
-
}
1833
-
if _, err := cw.WriteString(string("dependencies")); err != nil {
1834
-
return err
1835
-
}
1836
-
1837
-
if len(t.Dependencies) > 8192 {
1838
-
return xerrors.Errorf("Slice value in field t.Dependencies was too long")
1839
-
}
1840
-
1841
-
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Dependencies))); err != nil {
1842
-
return err
1843
-
}
1844
-
for _, v := range t.Dependencies {
1845
-
if err := v.MarshalCBOR(cw); err != nil {
1846
-
return err
1847
-
}
1848
-
1849
-
}
1850
-
return nil
1851
-
}
1852
-
1853
-
func (t *Pipeline_Workflow) UnmarshalCBOR(r io.Reader) (err error) {
1854
-
*t = Pipeline_Workflow{}
1855
-
1856
-
cr := cbg.NewCborReader(r)
1857
-
1858
-
maj, extra, err := cr.ReadHeader()
1859
-
if err != nil {
1860
-
return err
1861
-
}
1862
-
defer func() {
1863
-
if err == io.EOF {
1864
-
err = io.ErrUnexpectedEOF
1865
-
}
1866
-
}()
1867
-
1868
-
if maj != cbg.MajMap {
1869
-
return fmt.Errorf("cbor input should be of type map")
1870
-
}
1871
-
1872
-
if extra > cbg.MaxLength {
1873
-
return fmt.Errorf("Pipeline_Workflow: map struct too large (%d)", extra)
1874
-
}
1875
-
1876
-
n := extra
1877
-
1878
-
nameBuf := make([]byte, 12)
1879
-
for i := uint64(0); i < n; i++ {
1880
-
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1881
-
if err != nil {
1882
-
return err
1883
-
}
1884
-
1885
-
if !ok {
1886
-
// Field doesn't exist on this type, so ignore it
1887
-
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1888
-
return err
1889
-
}
1890
-
continue
1891
-
}
1892
-
1893
-
switch string(nameBuf[:nameLen]) {
1894
-
// t.Name (string) (string)
1895
-
case "name":
1896
-
1897
-
{
1898
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1899
-
if err != nil {
1900
-
return err
1901
-
}
1902
-
1903
-
t.Name = string(sval)
1904
-
}
1905
-
// t.Clone (tangled.Pipeline_CloneOpts) (struct)
1906
-
case "clone":
1907
-
1908
-
{
1909
-
1910
-
b, err := cr.ReadByte()
1911
-
if err != nil {
1912
-
return err
1913
-
}
1914
-
if b != cbg.CborNull[0] {
1915
-
if err := cr.UnreadByte(); err != nil {
1916
-
return err
1917
-
}
1918
-
t.Clone = new(Pipeline_CloneOpts)
1919
-
if err := t.Clone.UnmarshalCBOR(cr); err != nil {
1920
-
return xerrors.Errorf("unmarshaling t.Clone pointer: %w", err)
1921
-
}
1922
-
}
1923
-
1924
-
}
1925
-
// t.Steps ([]*tangled.Pipeline_Step) (slice)
1926
-
case "steps":
1927
-
1928
-
maj, extra, err = cr.ReadHeader()
1929
-
if err != nil {
1930
-
return err
1931
-
}
1932
-
1933
-
if extra > 8192 {
1934
-
return fmt.Errorf("t.Steps: array too large (%d)", extra)
1935
-
}
1936
-
1937
-
if maj != cbg.MajArray {
1938
-
return fmt.Errorf("expected cbor array")
1939
-
}
1940
-
1941
-
if extra > 0 {
1942
-
t.Steps = make([]*Pipeline_Step, extra)
1943
-
}
1944
-
1945
-
for i := 0; i < int(extra); i++ {
1946
-
{
1947
-
var maj byte
1948
-
var extra uint64
1949
-
var err error
1950
-
_ = maj
1951
-
_ = extra
1952
-
_ = err
1953
-
1954
-
{
1955
-
1956
-
b, err := cr.ReadByte()
1957
-
if err != nil {
1958
-
return err
1959
-
}
1960
-
if b != cbg.CborNull[0] {
1961
-
if err := cr.UnreadByte(); err != nil {
1962
-
return err
1963
-
}
1964
-
t.Steps[i] = new(Pipeline_Step)
1965
-
if err := t.Steps[i].UnmarshalCBOR(cr); err != nil {
1966
-
return xerrors.Errorf("unmarshaling t.Steps[i] pointer: %w", err)
1967
-
}
1968
-
}
1969
-
1970
-
}
1971
-
1972
-
}
1973
-
}
1974
-
// t.Environment ([]*tangled.Pipeline_Workflow_Environment_Elem) (slice)
1975
-
case "environment":
1976
-
1977
-
maj, extra, err = cr.ReadHeader()
1978
-
if err != nil {
1979
-
return err
1980
-
}
1981
-
1982
-
if extra > 8192 {
1983
-
return fmt.Errorf("t.Environment: array too large (%d)", extra)
1984
-
}
1985
-
1986
-
if maj != cbg.MajArray {
1987
-
return fmt.Errorf("expected cbor array")
1988
-
}
1989
-
1990
-
if extra > 0 {
1991
-
t.Environment = make([]*Pipeline_Workflow_Environment_Elem, extra)
1992
-
}
1993
-
1994
-
for i := 0; i < int(extra); i++ {
1995
-
{
1996
-
var maj byte
1997
-
var extra uint64
1998
-
var err error
1999
-
_ = maj
2000
-
_ = extra
2001
-
_ = err
2002
-
2003
-
{
2004
-
2005
-
b, err := cr.ReadByte()
2006
-
if err != nil {
2007
-
return err
2008
-
}
2009
-
if b != cbg.CborNull[0] {
2010
-
if err := cr.UnreadByte(); err != nil {
2011
-
return err
2012
-
}
2013
-
t.Environment[i] = new(Pipeline_Workflow_Environment_Elem)
2014
-
if err := t.Environment[i].UnmarshalCBOR(cr); err != nil {
2015
-
return xerrors.Errorf("unmarshaling t.Environment[i] pointer: %w", err)
2016
-
}
2017
-
}
2018
-
2019
-
}
2020
-
2021
-
}
2022
-
}
2023
-
// t.Dependencies ([]tangled.Pipeline_Dependencies_Elem) (slice)
2024
-
case "dependencies":
2025
-
2026
-
maj, extra, err = cr.ReadHeader()
2027
-
if err != nil {
2028
-
return err
2029
-
}
2030
-
2031
-
if extra > 8192 {
2032
-
return fmt.Errorf("t.Dependencies: array too large (%d)", extra)
2033
-
}
2034
-
2035
-
if maj != cbg.MajArray {
2036
-
return fmt.Errorf("expected cbor array")
2037
-
}
2038
-
2039
-
if extra > 0 {
2040
-
t.Dependencies = make([]Pipeline_Dependencies_Elem, extra)
2041
-
}
2042
-
2043
-
for i := 0; i < int(extra); i++ {
2044
-
{
2045
-
var maj byte
2046
-
var extra uint64
2047
-
var err error
2048
-
_ = maj
2049
-
_ = extra
2050
-
_ = err
2051
-
2052
-
{
2053
-
2054
-
if err := t.Dependencies[i].UnmarshalCBOR(cr); err != nil {
2055
-
return xerrors.Errorf("unmarshaling t.Dependencies[i]: %w", err)
2056
-
}
2057
-
2058
-
}
2059
-
2060
-
}
2061
-
}
2062
-
2063
-
default:
2064
-
// Field doesn't exist on this type, so ignore it
2065
-
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
2066
-
return err
2067
-
}
2068
-
}
2069
-
}
2070
-
2071
-
return nil
2072
-
}
2073
-
func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error {
2074
-
if t == nil {
2075
-
_, err := w.Write(cbg.CborNull)
2076
-
return err
2077
-
}
2078
-
2079
-
cw := cbg.NewCborWriter(w)
2080
-
2081
-
if _, err := cw.Write([]byte{162}); err != nil {
2082
-
return err
2083
-
}
2084
-
2085
-
// t.Key (string) (string)
2086
-
if len("key") > 1000000 {
2087
-
return xerrors.Errorf("Value in field \"key\" was too long")
2088
-
}
2089
-
2090
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
2091
-
return err
2092
-
}
2093
-
if _, err := cw.WriteString(string("key")); err != nil {
2094
-
return err
2095
-
}
2096
-
2097
-
if len(t.Key) > 1000000 {
2098
-
return xerrors.Errorf("Value in field t.Key was too long")
2099
-
}
2100
-
2101
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
2102
-
return err
2103
-
}
2104
-
if _, err := cw.WriteString(string(t.Key)); err != nil {
2105
-
return err
2106
-
}
2107
-
2108
-
// t.Value (string) (string)
2109
-
if len("value") > 1000000 {
2110
-
return xerrors.Errorf("Value in field \"value\" was too long")
2111
-
}
2112
-
2113
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
2114
-
return err
2115
-
}
2116
-
if _, err := cw.WriteString(string("value")); err != nil {
2117
-
return err
2118
-
}
2119
-
2120
-
if len(t.Value) > 1000000 {
2121
-
return xerrors.Errorf("Value in field t.Value was too long")
2122
-
}
2123
-
2124
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
2125
-
return err
2126
-
}
2127
-
if _, err := cw.WriteString(string(t.Value)); err != nil {
2128
-
return err
2129
-
}
2130
-
return nil
2131
-
}
2132
-
2133
-
func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) {
2134
-
*t = Pipeline_Workflow_Environment_Elem{}
2135
-
2136
-
cr := cbg.NewCborReader(r)
2137
-
2138
-
maj, extra, err := cr.ReadHeader()
2139
-
if err != nil {
2140
-
return err
2141
-
}
2142
-
defer func() {
2143
-
if err == io.EOF {
2144
-
err = io.ErrUnexpectedEOF
2145
-
}
2146
-
}()
2147
-
2148
-
if maj != cbg.MajMap {
2149
-
return fmt.Errorf("cbor input should be of type map")
2150
-
}
2151
-
2152
-
if extra > cbg.MaxLength {
2153
-
return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra)
2154
-
}
2155
-
2156
-
n := extra
2157
-
2158
-
nameBuf := make([]byte, 5)
2159
-
for i := uint64(0); i < n; i++ {
2160
-
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
2161
-
if err != nil {
2162
-
return err
2163
-
}
2164
-
2165
-
if !ok {
2166
-
// Field doesn't exist on this type, so ignore it
2167
-
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
2168
-
return err
2169
-
}
2170
-
continue
2171
-
}
2172
-
2173
-
switch string(nameBuf[:nameLen]) {
2174
-
// t.Key (string) (string)
2175
-
case "key":
2176
-
2177
-
{
2178
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2179
-
if err != nil {
2180
-
return err
2181
-
}
2182
-
2183
-
t.Key = string(sval)
2184
-
}
2185
-
// t.Value (string) (string)
2186
-
case "value":
2187
-
2188
-
{
2189
-
sval, err := cbg.ReadStringWithMax(cr, 1000000)
2190
-
if err != nil {
2191
-
return err
2192
-
}
2193
-
2194
-
t.Value = string(sval)
2195
-
}
2196
-
2197
-
default:
2198
-
// Field doesn't exist on this type, so ignore it
2199
-
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
2200
-
return err
2201
-
}
2202
-
}
2203
-
}
2204
-
2205
-
return nil
2206
-
}
2207
func (t *Pipeline_Dependencies_Elem) MarshalCBOR(w io.Writer) error {
2208
if t == nil {
2209
_, err := w.Write(cbg.CborNull)
···
3620
}
3621
3622
t.DefaultBranch = string(sval)
3623
}
3624
3625
default:
···
676
677
cw := cbg.NewCborWriter(w)
678
679
+
if _, err := cw.Write([]byte{168}); err != nil {
680
return err
681
}
682
···
700
return err
701
}
702
if _, err := cw.WriteString(string(t.Ref)); err != nil {
703
+
return err
704
+
}
705
+
706
+
// t.Meta (tangled.GitRefUpdate_Meta) (struct)
707
+
if len("meta") > 1000000 {
708
+
return xerrors.Errorf("Value in field \"meta\" was too long")
709
+
}
710
+
711
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("meta"))); err != nil {
712
+
return err
713
+
}
714
+
if _, err := cw.WriteString(string("meta")); err != nil {
715
+
return err
716
+
}
717
+
718
+
if err := t.Meta.MarshalCBOR(cw); err != nil {
719
return err
720
}
721
···
907
908
t.Ref = string(sval)
909
}
910
+
// t.Meta (tangled.GitRefUpdate_Meta) (struct)
911
+
case "meta":
912
+
913
+
{
914
+
915
+
b, err := cr.ReadByte()
916
+
if err != nil {
917
+
return err
918
+
}
919
+
if b != cbg.CborNull[0] {
920
+
if err := cr.UnreadByte(); err != nil {
921
+
return err
922
+
}
923
+
t.Meta = new(GitRefUpdate_Meta)
924
+
if err := t.Meta.UnmarshalCBOR(cr); err != nil {
925
+
return xerrors.Errorf("unmarshaling t.Meta pointer: %w", err)
926
+
}
927
+
}
928
+
929
+
}
930
// t.LexiconTypeID (string) (string)
931
case "$type":
932
···
992
}
993
994
t.CommitterDid = string(sval)
995
+
}
996
+
997
+
default:
998
+
// Field doesn't exist on this type, so ignore it
999
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1000
+
return err
1001
+
}
1002
+
}
1003
+
}
1004
+
1005
+
return nil
1006
+
}
1007
+
func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error {
1008
+
if t == nil {
1009
+
_, err := w.Write(cbg.CborNull)
1010
+
return err
1011
+
}
1012
+
1013
+
cw := cbg.NewCborWriter(w)
1014
+
1015
+
if _, err := cw.Write([]byte{162}); err != nil {
1016
+
return err
1017
+
}
1018
+
1019
+
// t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct)
1020
+
if len("commitCount") > 1000000 {
1021
+
return xerrors.Errorf("Value in field \"commitCount\" was too long")
1022
+
}
1023
+
1024
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commitCount"))); err != nil {
1025
+
return err
1026
+
}
1027
+
if _, err := cw.WriteString(string("commitCount")); err != nil {
1028
+
return err
1029
+
}
1030
+
1031
+
if err := t.CommitCount.MarshalCBOR(cw); err != nil {
1032
+
return err
1033
+
}
1034
+
1035
+
// t.IsDefaultRef (bool) (bool)
1036
+
if len("isDefaultRef") > 1000000 {
1037
+
return xerrors.Errorf("Value in field \"isDefaultRef\" was too long")
1038
+
}
1039
+
1040
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("isDefaultRef"))); err != nil {
1041
+
return err
1042
+
}
1043
+
if _, err := cw.WriteString(string("isDefaultRef")); err != nil {
1044
+
return err
1045
+
}
1046
+
1047
+
if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil {
1048
+
return err
1049
+
}
1050
+
return nil
1051
+
}
1052
+
1053
+
func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) {
1054
+
*t = GitRefUpdate_Meta{}
1055
+
1056
+
cr := cbg.NewCborReader(r)
1057
+
1058
+
maj, extra, err := cr.ReadHeader()
1059
+
if err != nil {
1060
+
return err
1061
+
}
1062
+
defer func() {
1063
+
if err == io.EOF {
1064
+
err = io.ErrUnexpectedEOF
1065
+
}
1066
+
}()
1067
+
1068
+
if maj != cbg.MajMap {
1069
+
return fmt.Errorf("cbor input should be of type map")
1070
+
}
1071
+
1072
+
if extra > cbg.MaxLength {
1073
+
return fmt.Errorf("GitRefUpdate_Meta: map struct too large (%d)", extra)
1074
+
}
1075
+
1076
+
n := extra
1077
+
1078
+
nameBuf := make([]byte, 12)
1079
+
for i := uint64(0); i < n; i++ {
1080
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1081
+
if err != nil {
1082
+
return err
1083
+
}
1084
+
1085
+
if !ok {
1086
+
// Field doesn't exist on this type, so ignore it
1087
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1088
+
return err
1089
+
}
1090
+
continue
1091
+
}
1092
+
1093
+
switch string(nameBuf[:nameLen]) {
1094
+
// t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct)
1095
+
case "commitCount":
1096
+
1097
+
{
1098
+
1099
+
b, err := cr.ReadByte()
1100
+
if err != nil {
1101
+
return err
1102
+
}
1103
+
if b != cbg.CborNull[0] {
1104
+
if err := cr.UnreadByte(); err != nil {
1105
+
return err
1106
+
}
1107
+
t.CommitCount = new(GitRefUpdate_Meta_CommitCount)
1108
+
if err := t.CommitCount.UnmarshalCBOR(cr); err != nil {
1109
+
return xerrors.Errorf("unmarshaling t.CommitCount pointer: %w", err)
1110
+
}
1111
+
}
1112
+
1113
+
}
1114
+
// t.IsDefaultRef (bool) (bool)
1115
+
case "isDefaultRef":
1116
+
1117
+
maj, extra, err = cr.ReadHeader()
1118
+
if err != nil {
1119
+
return err
1120
+
}
1121
+
if maj != cbg.MajOther {
1122
+
return fmt.Errorf("booleans must be major type 7")
1123
+
}
1124
+
switch extra {
1125
+
case 20:
1126
+
t.IsDefaultRef = false
1127
+
case 21:
1128
+
t.IsDefaultRef = true
1129
+
default:
1130
+
return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra)
1131
+
}
1132
+
1133
+
default:
1134
+
// Field doesn't exist on this type, so ignore it
1135
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1136
+
return err
1137
+
}
1138
+
}
1139
+
}
1140
+
1141
+
return nil
1142
+
}
1143
+
func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error {
1144
+
if t == nil {
1145
+
_, err := w.Write(cbg.CborNull)
1146
+
return err
1147
+
}
1148
+
1149
+
cw := cbg.NewCborWriter(w)
1150
+
fieldCount := 1
1151
+
1152
+
if t.ByEmail == nil {
1153
+
fieldCount--
1154
+
}
1155
+
1156
+
if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil {
1157
+
return err
1158
+
}
1159
+
1160
+
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
1161
+
if t.ByEmail != nil {
1162
+
1163
+
if len("byEmail") > 1000000 {
1164
+
return xerrors.Errorf("Value in field \"byEmail\" was too long")
1165
+
}
1166
+
1167
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("byEmail"))); err != nil {
1168
+
return err
1169
+
}
1170
+
if _, err := cw.WriteString(string("byEmail")); err != nil {
1171
+
return err
1172
+
}
1173
+
1174
+
if len(t.ByEmail) > 8192 {
1175
+
return xerrors.Errorf("Slice value in field t.ByEmail was too long")
1176
+
}
1177
+
1178
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ByEmail))); err != nil {
1179
+
return err
1180
+
}
1181
+
for _, v := range t.ByEmail {
1182
+
if err := v.MarshalCBOR(cw); err != nil {
1183
+
return err
1184
+
}
1185
+
1186
+
}
1187
+
}
1188
+
return nil
1189
+
}
1190
+
1191
+
func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) {
1192
+
*t = GitRefUpdate_Meta_CommitCount{}
1193
+
1194
+
cr := cbg.NewCborReader(r)
1195
+
1196
+
maj, extra, err := cr.ReadHeader()
1197
+
if err != nil {
1198
+
return err
1199
+
}
1200
+
defer func() {
1201
+
if err == io.EOF {
1202
+
err = io.ErrUnexpectedEOF
1203
+
}
1204
+
}()
1205
+
1206
+
if maj != cbg.MajMap {
1207
+
return fmt.Errorf("cbor input should be of type map")
1208
+
}
1209
+
1210
+
if extra > cbg.MaxLength {
1211
+
return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra)
1212
+
}
1213
+
1214
+
n := extra
1215
+
1216
+
nameBuf := make([]byte, 7)
1217
+
for i := uint64(0); i < n; i++ {
1218
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1219
+
if err != nil {
1220
+
return err
1221
+
}
1222
+
1223
+
if !ok {
1224
+
// Field doesn't exist on this type, so ignore it
1225
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1226
+
return err
1227
+
}
1228
+
continue
1229
+
}
1230
+
1231
+
switch string(nameBuf[:nameLen]) {
1232
+
// t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice)
1233
+
case "byEmail":
1234
+
1235
+
maj, extra, err = cr.ReadHeader()
1236
+
if err != nil {
1237
+
return err
1238
+
}
1239
+
1240
+
if extra > 8192 {
1241
+
return fmt.Errorf("t.ByEmail: array too large (%d)", extra)
1242
+
}
1243
+
1244
+
if maj != cbg.MajArray {
1245
+
return fmt.Errorf("expected cbor array")
1246
+
}
1247
+
1248
+
if extra > 0 {
1249
+
t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra)
1250
+
}
1251
+
1252
+
for i := 0; i < int(extra); i++ {
1253
+
{
1254
+
var maj byte
1255
+
var extra uint64
1256
+
var err error
1257
+
_ = maj
1258
+
_ = extra
1259
+
_ = err
1260
+
1261
+
{
1262
+
1263
+
b, err := cr.ReadByte()
1264
+
if err != nil {
1265
+
return err
1266
+
}
1267
+
if b != cbg.CborNull[0] {
1268
+
if err := cr.UnreadByte(); err != nil {
1269
+
return err
1270
+
}
1271
+
t.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem)
1272
+
if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil {
1273
+
return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err)
1274
+
}
1275
+
}
1276
+
1277
+
}
1278
+
1279
+
}
1280
+
}
1281
+
1282
+
default:
1283
+
// Field doesn't exist on this type, so ignore it
1284
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
1285
+
return err
1286
+
}
1287
+
}
1288
+
}
1289
+
1290
+
return nil
1291
+
}
1292
+
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error {
1293
+
if t == nil {
1294
+
_, err := w.Write(cbg.CborNull)
1295
+
return err
1296
+
}
1297
+
1298
+
cw := cbg.NewCborWriter(w)
1299
+
1300
+
if _, err := cw.Write([]byte{162}); err != nil {
1301
+
return err
1302
+
}
1303
+
1304
+
// t.Count (int64) (int64)
1305
+
if len("count") > 1000000 {
1306
+
return xerrors.Errorf("Value in field \"count\" was too long")
1307
+
}
1308
+
1309
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("count"))); err != nil {
1310
+
return err
1311
+
}
1312
+
if _, err := cw.WriteString(string("count")); err != nil {
1313
+
return err
1314
+
}
1315
+
1316
+
if t.Count >= 0 {
1317
+
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.Count)); err != nil {
1318
+
return err
1319
+
}
1320
+
} else {
1321
+
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.Count-1)); err != nil {
1322
+
return err
1323
+
}
1324
+
}
1325
+
1326
+
// t.Email (string) (string)
1327
+
if len("email") > 1000000 {
1328
+
return xerrors.Errorf("Value in field \"email\" was too long")
1329
+
}
1330
+
1331
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("email"))); err != nil {
1332
+
return err
1333
+
}
1334
+
if _, err := cw.WriteString(string("email")); err != nil {
1335
+
return err
1336
+
}
1337
+
1338
+
if len(t.Email) > 1000000 {
1339
+
return xerrors.Errorf("Value in field t.Email was too long")
1340
+
}
1341
+
1342
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Email))); err != nil {
1343
+
return err
1344
+
}
1345
+
if _, err := cw.WriteString(string(t.Email)); err != nil {
1346
+
return err
1347
+
}
1348
+
return nil
1349
+
}
1350
+
1351
+
func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) {
1352
+
*t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}
1353
+
1354
+
cr := cbg.NewCborReader(r)
1355
+
1356
+
maj, extra, err := cr.ReadHeader()
1357
+
if err != nil {
1358
+
return err
1359
+
}
1360
+
defer func() {
1361
+
if err == io.EOF {
1362
+
err = io.ErrUnexpectedEOF
1363
+
}
1364
+
}()
1365
+
1366
+
if maj != cbg.MajMap {
1367
+
return fmt.Errorf("cbor input should be of type map")
1368
+
}
1369
+
1370
+
if extra > cbg.MaxLength {
1371
+
return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra)
1372
+
}
1373
+
1374
+
n := extra
1375
+
1376
+
nameBuf := make([]byte, 5)
1377
+
for i := uint64(0); i < n; i++ {
1378
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
1379
+
if err != nil {
1380
+
return err
1381
+
}
1382
+
1383
+
if !ok {
1384
+
// Field doesn't exist on this type, so ignore it
1385
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
1386
+
return err
1387
+
}
1388
+
continue
1389
+
}
1390
+
1391
+
switch string(nameBuf[:nameLen]) {
1392
+
// t.Count (int64) (int64)
1393
+
case "count":
1394
+
{
1395
+
maj, extra, err := cr.ReadHeader()
1396
+
if err != nil {
1397
+
return err
1398
+
}
1399
+
var extraI int64
1400
+
switch maj {
1401
+
case cbg.MajUnsignedInt:
1402
+
extraI = int64(extra)
1403
+
if extraI < 0 {
1404
+
return fmt.Errorf("int64 positive overflow")
1405
+
}
1406
+
case cbg.MajNegativeInt:
1407
+
extraI = int64(extra)
1408
+
if extraI < 0 {
1409
+
return fmt.Errorf("int64 negative overflow")
1410
+
}
1411
+
extraI = -1 - extraI
1412
+
default:
1413
+
return fmt.Errorf("wrong type for int64 field: %d", maj)
1414
+
}
1415
+
1416
+
t.Count = int64(extraI)
1417
+
}
1418
+
// t.Email (string) (string)
1419
+
case "email":
1420
+
1421
+
{
1422
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
1423
+
if err != nil {
1424
+
return err
1425
+
}
1426
+
1427
+
t.Email = string(sval)
1428
}
1429
1430
default:
···
2188
2189
return nil
2190
}
2191
func (t *Pipeline_Dependencies_Elem) MarshalCBOR(w io.Writer) error {
2192
if t == nil {
2193
_, err := w.Write(cbg.CborNull)
···
3604
}
3605
3606
t.DefaultBranch = string(sval)
3607
+
}
3608
+
3609
+
default:
3610
+
// Field doesn't exist on this type, so ignore it
3611
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3612
+
return err
3613
+
}
3614
+
}
3615
+
}
3616
+
3617
+
return nil
3618
+
}
3619
+
func (t *Pipeline_Workflow) MarshalCBOR(w io.Writer) error {
3620
+
if t == nil {
3621
+
_, err := w.Write(cbg.CborNull)
3622
+
return err
3623
+
}
3624
+
3625
+
cw := cbg.NewCborWriter(w)
3626
+
3627
+
if _, err := cw.Write([]byte{165}); err != nil {
3628
+
return err
3629
+
}
3630
+
3631
+
// t.Name (string) (string)
3632
+
if len("name") > 1000000 {
3633
+
return xerrors.Errorf("Value in field \"name\" was too long")
3634
+
}
3635
+
3636
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("name"))); err != nil {
3637
+
return err
3638
+
}
3639
+
if _, err := cw.WriteString(string("name")); err != nil {
3640
+
return err
3641
+
}
3642
+
3643
+
if len(t.Name) > 1000000 {
3644
+
return xerrors.Errorf("Value in field t.Name was too long")
3645
+
}
3646
+
3647
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Name))); err != nil {
3648
+
return err
3649
+
}
3650
+
if _, err := cw.WriteString(string(t.Name)); err != nil {
3651
+
return err
3652
+
}
3653
+
3654
+
// t.Clone (tangled.Pipeline_CloneOpts) (struct)
3655
+
if len("clone") > 1000000 {
3656
+
return xerrors.Errorf("Value in field \"clone\" was too long")
3657
+
}
3658
+
3659
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("clone"))); err != nil {
3660
+
return err
3661
+
}
3662
+
if _, err := cw.WriteString(string("clone")); err != nil {
3663
+
return err
3664
+
}
3665
+
3666
+
if err := t.Clone.MarshalCBOR(cw); err != nil {
3667
+
return err
3668
+
}
3669
+
3670
+
// t.Steps ([]*tangled.Pipeline_Step) (slice)
3671
+
if len("steps") > 1000000 {
3672
+
return xerrors.Errorf("Value in field \"steps\" was too long")
3673
+
}
3674
+
3675
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("steps"))); err != nil {
3676
+
return err
3677
+
}
3678
+
if _, err := cw.WriteString(string("steps")); err != nil {
3679
+
return err
3680
+
}
3681
+
3682
+
if len(t.Steps) > 8192 {
3683
+
return xerrors.Errorf("Slice value in field t.Steps was too long")
3684
+
}
3685
+
3686
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Steps))); err != nil {
3687
+
return err
3688
+
}
3689
+
for _, v := range t.Steps {
3690
+
if err := v.MarshalCBOR(cw); err != nil {
3691
+
return err
3692
+
}
3693
+
3694
+
}
3695
+
3696
+
// t.Environment ([]*tangled.Pipeline_Workflow_Environment_Elem) (slice)
3697
+
if len("environment") > 1000000 {
3698
+
return xerrors.Errorf("Value in field \"environment\" was too long")
3699
+
}
3700
+
3701
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("environment"))); err != nil {
3702
+
return err
3703
+
}
3704
+
if _, err := cw.WriteString(string("environment")); err != nil {
3705
+
return err
3706
+
}
3707
+
3708
+
if len(t.Environment) > 8192 {
3709
+
return xerrors.Errorf("Slice value in field t.Environment was too long")
3710
+
}
3711
+
3712
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Environment))); err != nil {
3713
+
return err
3714
+
}
3715
+
for _, v := range t.Environment {
3716
+
if err := v.MarshalCBOR(cw); err != nil {
3717
+
return err
3718
+
}
3719
+
3720
+
}
3721
+
3722
+
// t.Dependencies ([]tangled.Pipeline_Dependencies_Elem) (slice)
3723
+
if len("dependencies") > 1000000 {
3724
+
return xerrors.Errorf("Value in field \"dependencies\" was too long")
3725
+
}
3726
+
3727
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("dependencies"))); err != nil {
3728
+
return err
3729
+
}
3730
+
if _, err := cw.WriteString(string("dependencies")); err != nil {
3731
+
return err
3732
+
}
3733
+
3734
+
if len(t.Dependencies) > 8192 {
3735
+
return xerrors.Errorf("Slice value in field t.Dependencies was too long")
3736
+
}
3737
+
3738
+
if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.Dependencies))); err != nil {
3739
+
return err
3740
+
}
3741
+
for _, v := range t.Dependencies {
3742
+
if err := v.MarshalCBOR(cw); err != nil {
3743
+
return err
3744
+
}
3745
+
3746
+
}
3747
+
return nil
3748
+
}
3749
+
3750
+
func (t *Pipeline_Workflow) UnmarshalCBOR(r io.Reader) (err error) {
3751
+
*t = Pipeline_Workflow{}
3752
+
3753
+
cr := cbg.NewCborReader(r)
3754
+
3755
+
maj, extra, err := cr.ReadHeader()
3756
+
if err != nil {
3757
+
return err
3758
+
}
3759
+
defer func() {
3760
+
if err == io.EOF {
3761
+
err = io.ErrUnexpectedEOF
3762
+
}
3763
+
}()
3764
+
3765
+
if maj != cbg.MajMap {
3766
+
return fmt.Errorf("cbor input should be of type map")
3767
+
}
3768
+
3769
+
if extra > cbg.MaxLength {
3770
+
return fmt.Errorf("Pipeline_Workflow: map struct too large (%d)", extra)
3771
+
}
3772
+
3773
+
n := extra
3774
+
3775
+
nameBuf := make([]byte, 12)
3776
+
for i := uint64(0); i < n; i++ {
3777
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
3778
+
if err != nil {
3779
+
return err
3780
+
}
3781
+
3782
+
if !ok {
3783
+
// Field doesn't exist on this type, so ignore it
3784
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
3785
+
return err
3786
+
}
3787
+
continue
3788
+
}
3789
+
3790
+
switch string(nameBuf[:nameLen]) {
3791
+
// t.Name (string) (string)
3792
+
case "name":
3793
+
3794
+
{
3795
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
3796
+
if err != nil {
3797
+
return err
3798
+
}
3799
+
3800
+
t.Name = string(sval)
3801
+
}
3802
+
// t.Clone (tangled.Pipeline_CloneOpts) (struct)
3803
+
case "clone":
3804
+
3805
+
{
3806
+
3807
+
b, err := cr.ReadByte()
3808
+
if err != nil {
3809
+
return err
3810
+
}
3811
+
if b != cbg.CborNull[0] {
3812
+
if err := cr.UnreadByte(); err != nil {
3813
+
return err
3814
+
}
3815
+
t.Clone = new(Pipeline_CloneOpts)
3816
+
if err := t.Clone.UnmarshalCBOR(cr); err != nil {
3817
+
return xerrors.Errorf("unmarshaling t.Clone pointer: %w", err)
3818
+
}
3819
+
}
3820
+
3821
+
}
3822
+
// t.Steps ([]*tangled.Pipeline_Step) (slice)
3823
+
case "steps":
3824
+
3825
+
maj, extra, err = cr.ReadHeader()
3826
+
if err != nil {
3827
+
return err
3828
+
}
3829
+
3830
+
if extra > 8192 {
3831
+
return fmt.Errorf("t.Steps: array too large (%d)", extra)
3832
+
}
3833
+
3834
+
if maj != cbg.MajArray {
3835
+
return fmt.Errorf("expected cbor array")
3836
+
}
3837
+
3838
+
if extra > 0 {
3839
+
t.Steps = make([]*Pipeline_Step, extra)
3840
+
}
3841
+
3842
+
for i := 0; i < int(extra); i++ {
3843
+
{
3844
+
var maj byte
3845
+
var extra uint64
3846
+
var err error
3847
+
_ = maj
3848
+
_ = extra
3849
+
_ = err
3850
+
3851
+
{
3852
+
3853
+
b, err := cr.ReadByte()
3854
+
if err != nil {
3855
+
return err
3856
+
}
3857
+
if b != cbg.CborNull[0] {
3858
+
if err := cr.UnreadByte(); err != nil {
3859
+
return err
3860
+
}
3861
+
t.Steps[i] = new(Pipeline_Step)
3862
+
if err := t.Steps[i].UnmarshalCBOR(cr); err != nil {
3863
+
return xerrors.Errorf("unmarshaling t.Steps[i] pointer: %w", err)
3864
+
}
3865
+
}
3866
+
3867
+
}
3868
+
3869
+
}
3870
+
}
3871
+
// t.Environment ([]*tangled.Pipeline_Workflow_Environment_Elem) (slice)
3872
+
case "environment":
3873
+
3874
+
maj, extra, err = cr.ReadHeader()
3875
+
if err != nil {
3876
+
return err
3877
+
}
3878
+
3879
+
if extra > 8192 {
3880
+
return fmt.Errorf("t.Environment: array too large (%d)", extra)
3881
+
}
3882
+
3883
+
if maj != cbg.MajArray {
3884
+
return fmt.Errorf("expected cbor array")
3885
+
}
3886
+
3887
+
if extra > 0 {
3888
+
t.Environment = make([]*Pipeline_Workflow_Environment_Elem, extra)
3889
+
}
3890
+
3891
+
for i := 0; i < int(extra); i++ {
3892
+
{
3893
+
var maj byte
3894
+
var extra uint64
3895
+
var err error
3896
+
_ = maj
3897
+
_ = extra
3898
+
_ = err
3899
+
3900
+
{
3901
+
3902
+
b, err := cr.ReadByte()
3903
+
if err != nil {
3904
+
return err
3905
+
}
3906
+
if b != cbg.CborNull[0] {
3907
+
if err := cr.UnreadByte(); err != nil {
3908
+
return err
3909
+
}
3910
+
t.Environment[i] = new(Pipeline_Workflow_Environment_Elem)
3911
+
if err := t.Environment[i].UnmarshalCBOR(cr); err != nil {
3912
+
return xerrors.Errorf("unmarshaling t.Environment[i] pointer: %w", err)
3913
+
}
3914
+
}
3915
+
3916
+
}
3917
+
3918
+
}
3919
+
}
3920
+
// t.Dependencies ([]tangled.Pipeline_Dependencies_Elem) (slice)
3921
+
case "dependencies":
3922
+
3923
+
maj, extra, err = cr.ReadHeader()
3924
+
if err != nil {
3925
+
return err
3926
+
}
3927
+
3928
+
if extra > 8192 {
3929
+
return fmt.Errorf("t.Dependencies: array too large (%d)", extra)
3930
+
}
3931
+
3932
+
if maj != cbg.MajArray {
3933
+
return fmt.Errorf("expected cbor array")
3934
+
}
3935
+
3936
+
if extra > 0 {
3937
+
t.Dependencies = make([]Pipeline_Dependencies_Elem, extra)
3938
+
}
3939
+
3940
+
for i := 0; i < int(extra); i++ {
3941
+
{
3942
+
var maj byte
3943
+
var extra uint64
3944
+
var err error
3945
+
_ = maj
3946
+
_ = extra
3947
+
_ = err
3948
+
3949
+
{
3950
+
3951
+
if err := t.Dependencies[i].UnmarshalCBOR(cr); err != nil {
3952
+
return xerrors.Errorf("unmarshaling t.Dependencies[i]: %w", err)
3953
+
}
3954
+
3955
+
}
3956
+
3957
+
}
3958
+
}
3959
+
3960
+
default:
3961
+
// Field doesn't exist on this type, so ignore it
3962
+
if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil {
3963
+
return err
3964
+
}
3965
+
}
3966
+
}
3967
+
3968
+
return nil
3969
+
}
3970
+
func (t *Pipeline_Workflow_Environment_Elem) MarshalCBOR(w io.Writer) error {
3971
+
if t == nil {
3972
+
_, err := w.Write(cbg.CborNull)
3973
+
return err
3974
+
}
3975
+
3976
+
cw := cbg.NewCborWriter(w)
3977
+
3978
+
if _, err := cw.Write([]byte{162}); err != nil {
3979
+
return err
3980
+
}
3981
+
3982
+
// t.Key (string) (string)
3983
+
if len("key") > 1000000 {
3984
+
return xerrors.Errorf("Value in field \"key\" was too long")
3985
+
}
3986
+
3987
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("key"))); err != nil {
3988
+
return err
3989
+
}
3990
+
if _, err := cw.WriteString(string("key")); err != nil {
3991
+
return err
3992
+
}
3993
+
3994
+
if len(t.Key) > 1000000 {
3995
+
return xerrors.Errorf("Value in field t.Key was too long")
3996
+
}
3997
+
3998
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Key))); err != nil {
3999
+
return err
4000
+
}
4001
+
if _, err := cw.WriteString(string(t.Key)); err != nil {
4002
+
return err
4003
+
}
4004
+
4005
+
// t.Value (string) (string)
4006
+
if len("value") > 1000000 {
4007
+
return xerrors.Errorf("Value in field \"value\" was too long")
4008
+
}
4009
+
4010
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("value"))); err != nil {
4011
+
return err
4012
+
}
4013
+
if _, err := cw.WriteString(string("value")); err != nil {
4014
+
return err
4015
+
}
4016
+
4017
+
if len(t.Value) > 1000000 {
4018
+
return xerrors.Errorf("Value in field t.Value was too long")
4019
+
}
4020
+
4021
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Value))); err != nil {
4022
+
return err
4023
+
}
4024
+
if _, err := cw.WriteString(string(t.Value)); err != nil {
4025
+
return err
4026
+
}
4027
+
return nil
4028
+
}
4029
+
4030
+
func (t *Pipeline_Workflow_Environment_Elem) UnmarshalCBOR(r io.Reader) (err error) {
4031
+
*t = Pipeline_Workflow_Environment_Elem{}
4032
+
4033
+
cr := cbg.NewCborReader(r)
4034
+
4035
+
maj, extra, err := cr.ReadHeader()
4036
+
if err != nil {
4037
+
return err
4038
+
}
4039
+
defer func() {
4040
+
if err == io.EOF {
4041
+
err = io.ErrUnexpectedEOF
4042
+
}
4043
+
}()
4044
+
4045
+
if maj != cbg.MajMap {
4046
+
return fmt.Errorf("cbor input should be of type map")
4047
+
}
4048
+
4049
+
if extra > cbg.MaxLength {
4050
+
return fmt.Errorf("Pipeline_Workflow_Environment_Elem: map struct too large (%d)", extra)
4051
+
}
4052
+
4053
+
n := extra
4054
+
4055
+
nameBuf := make([]byte, 5)
4056
+
for i := uint64(0); i < n; i++ {
4057
+
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
4058
+
if err != nil {
4059
+
return err
4060
+
}
4061
+
4062
+
if !ok {
4063
+
// Field doesn't exist on this type, so ignore it
4064
+
if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil {
4065
+
return err
4066
+
}
4067
+
continue
4068
+
}
4069
+
4070
+
switch string(nameBuf[:nameLen]) {
4071
+
// t.Key (string) (string)
4072
+
case "key":
4073
+
4074
+
{
4075
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4076
+
if err != nil {
4077
+
return err
4078
+
}
4079
+
4080
+
t.Key = string(sval)
4081
+
}
4082
+
// t.Value (string) (string)
4083
+
case "value":
4084
+
4085
+
{
4086
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
4087
+
if err != nil {
4088
+
return err
4089
+
}
4090
+
4091
+
t.Value = string(sval)
4092
}
4093
4094
default:
+22
-7
api/tangled/gitrefUpdate.go
+22
-7
api/tangled/gitrefUpdate.go
···
4
5
// schema: sh.tangled.git.refUpdate
6
7
-
//import (
8
-
// "github.com/bluesky-social/indigo/lex/util"
9
-
//)
10
11
const (
12
GitRefUpdateNSID = "sh.tangled.git.refUpdate"
13
)
14
15
-
//func init() {
16
-
// util.RegisterType("sh.tangled.git.refUpdate", &GitRefUpdate{})
17
-
//} //
18
// RECORDTYPE: GitRefUpdate
19
type GitRefUpdate struct {
20
LexiconTypeID string `json:"$type,const=sh.tangled.git.refUpdate" cborgen:"$type,const=sh.tangled.git.refUpdate"`
21
// committerDid: did of the user that pushed this ref
22
-
CommitterDid string `json:"committerDid" cborgen:"committerDid"`
23
// newSha: new SHA of this ref
24
NewSha string `json:"newSha" cborgen:"newSha"`
25
// oldSha: old SHA of this ref
···
31
// repoName: name of the repo
32
RepoName string `json:"repoName" cborgen:"repoName"`
33
}
···
4
5
// schema: sh.tangled.git.refUpdate
6
7
+
import (
8
+
"github.com/bluesky-social/indigo/lex/util"
9
+
)
10
11
const (
12
GitRefUpdateNSID = "sh.tangled.git.refUpdate"
13
)
14
15
+
func init() {
16
+
util.RegisterType("sh.tangled.git.refUpdate", &GitRefUpdate{})
17
+
} //
18
// RECORDTYPE: GitRefUpdate
19
type GitRefUpdate struct {
20
LexiconTypeID string `json:"$type,const=sh.tangled.git.refUpdate" cborgen:"$type,const=sh.tangled.git.refUpdate"`
21
// committerDid: did of the user that pushed this ref
22
+
CommitterDid string `json:"committerDid" cborgen:"committerDid"`
23
+
Meta *GitRefUpdate_Meta `json:"meta" cborgen:"meta"`
24
// newSha: new SHA of this ref
25
NewSha string `json:"newSha" cborgen:"newSha"`
26
// oldSha: old SHA of this ref
···
32
// repoName: name of the repo
33
RepoName string `json:"repoName" cborgen:"repoName"`
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 {
42
+
ByEmail []*GitRefUpdate_Meta_CommitCount_ByEmail_Elem `json:"byEmail,omitempty" cborgen:"byEmail,omitempty"`
43
+
}
44
+
45
+
type GitRefUpdate_Meta_CommitCount_ByEmail_Elem struct {
46
+
Count int64 `json:"count" cborgen:"count"`
47
+
Email string `json:"email" cborgen:"email"`
48
+
}
+6
-6
api/tangled/tangledpipeline.go
+6
-6
api/tangled/tangledpipeline.go
···
4
5
// schema: sh.tangled.pipeline
6
7
-
//import (
8
-
// "github.com/bluesky-social/indigo/lex/util"
9
-
//)
10
11
const (
12
PipelineNSID = "sh.tangled.pipeline"
13
)
14
15
-
//func init() {
16
-
// util.RegisterType("sh.tangled.pipeline", &Pipeline{})
17
-
//} //
18
// RECORDTYPE: Pipeline
19
type Pipeline struct {
20
LexiconTypeID string `json:"$type,const=sh.tangled.pipeline" cborgen:"$type,const=sh.tangled.pipeline"`
···
4
5
// schema: sh.tangled.pipeline
6
7
+
import (
8
+
"github.com/bluesky-social/indigo/lex/util"
9
+
)
10
11
const (
12
PipelineNSID = "sh.tangled.pipeline"
13
)
14
15
+
func init() {
16
+
util.RegisterType("sh.tangled.pipeline", &Pipeline{})
17
+
} //
18
// RECORDTYPE: Pipeline
19
type Pipeline struct {
20
LexiconTypeID string `json:"$type,const=sh.tangled.pipeline" cborgen:"$type,const=sh.tangled.pipeline"`
+5
-2
cmd/gen.go
+5
-2
cmd/gen.go
···
17
tangled.ActorProfile{},
18
tangled.FeedStar{},
19
tangled.GitRefUpdate{},
20
tangled.GraphFollow{},
21
tangled.KnotMember{},
22
tangled.Pipeline{},
23
tangled.Pipeline_CloneOpts{},
24
-
tangled.Pipeline_Workflow{},
25
-
tangled.Pipeline_Workflow_Environment_Elem{},
26
tangled.Pipeline_Dependencies_Elem{},
27
tangled.Pipeline_ManualTriggerData{},
28
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
···
31
tangled.Pipeline_Step{},
32
tangled.Pipeline_TriggerMetadata{},
33
tangled.Pipeline_TriggerRepo{},
34
tangled.PublicKey{},
35
tangled.Repo{},
36
tangled.RepoArtifact{},
···
17
tangled.ActorProfile{},
18
tangled.FeedStar{},
19
tangled.GitRefUpdate{},
20
+
tangled.GitRefUpdate_Meta{},
21
+
tangled.GitRefUpdate_Meta_CommitCount{},
22
+
tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{},
23
tangled.GraphFollow{},
24
tangled.KnotMember{},
25
tangled.Pipeline{},
26
tangled.Pipeline_CloneOpts{},
27
tangled.Pipeline_Dependencies_Elem{},
28
tangled.Pipeline_ManualTriggerData{},
29
tangled.Pipeline_ManualTriggerData_Inputs_Elem{},
···
32
tangled.Pipeline_Step{},
33
tangled.Pipeline_TriggerMetadata{},
34
tangled.Pipeline_TriggerRepo{},
35
+
tangled.Pipeline_Workflow{},
36
+
tangled.Pipeline_Workflow_Environment_Elem{},
37
tangled.PublicKey{},
38
tangled.Repo{},
39
tangled.RepoArtifact{},
+99
-5
knotserver/git/post_receive.go
+99
-5
knotserver/git/post_receive.go
···
2
3
import (
4
"bufio"
5
"io"
6
"strings"
7
)
8
9
type PostReceiveLine struct {
10
-
OldSha string // old sha of reference being updated
11
-
NewSha string // new sha of reference being updated
12
-
Ref string // the reference being updated
13
}
14
15
func ParsePostReceive(buf io.Reader) ([]PostReceiveLine, error) {
···
27
ref := parts[2]
28
29
lines = append(lines, PostReceiveLine{
30
-
OldSha: oldSha,
31
-
NewSha: newSha,
32
Ref: ref,
33
})
34
}
···
39
40
return lines, nil
41
}
···
2
3
import (
4
"bufio"
5
+
"fmt"
6
"io"
7
"strings"
8
+
9
+
"tangled.sh/tangled.sh/core/api/tangled"
10
+
11
+
"github.com/go-git/go-git/v5/plumbing"
12
)
13
14
type PostReceiveLine struct {
15
+
OldSha plumbing.Hash // old sha of reference being updated
16
+
NewSha plumbing.Hash // new sha of reference being updated
17
+
Ref string // the reference being updated
18
}
19
20
func ParsePostReceive(buf io.Reader) ([]PostReceiveLine, error) {
···
32
ref := parts[2]
33
34
lines = append(lines, PostReceiveLine{
35
+
OldSha: plumbing.NewHash(oldSha),
36
+
NewSha: plumbing.NewHash(newSha),
37
Ref: ref,
38
})
39
}
···
44
45
return lines, nil
46
}
47
+
48
+
type RefUpdateMeta struct {
49
+
CommitCount CommitCount
50
+
IsDefaultRef bool
51
+
}
52
+
53
+
type CommitCount struct {
54
+
ByEmail map[string]int
55
+
}
56
+
57
+
func (g *GitRepo) RefUpdateMeta(line PostReceiveLine) RefUpdateMeta {
58
+
commitCount, err := g.newCommitCount(line)
59
+
if err != nil {
60
+
// TODO: non-fatal, log this
61
+
}
62
+
63
+
isDefaultRef, err := g.isDefaultBranch(line)
64
+
if err != nil {
65
+
// TODO: non-fatal, log this
66
+
}
67
+
68
+
return RefUpdateMeta{
69
+
CommitCount: commitCount,
70
+
IsDefaultRef: isDefaultRef,
71
+
}
72
+
}
73
+
74
+
func (g *GitRepo) newCommitCount(line PostReceiveLine) (CommitCount, error) {
75
+
byEmail := make(map[string]int)
76
+
commitCount := CommitCount{
77
+
ByEmail: byEmail,
78
+
}
79
+
80
+
if !line.NewSha.IsZero() {
81
+
output, err := g.revList(
82
+
fmt.Sprintf("--max-count=%d", 100),
83
+
fmt.Sprintf("%s..%s", line.OldSha.String(), line.NewSha.String()),
84
+
)
85
+
if err != nil {
86
+
return commitCount, fmt.Errorf("failed to run rev-list: %w", err)
87
+
}
88
+
89
+
lines := strings.Split(strings.TrimSpace(string(output)), "\n")
90
+
if len(lines) == 1 && lines[0] == "" {
91
+
return commitCount, nil
92
+
}
93
+
94
+
for _, item := range lines {
95
+
obj, err := g.r.CommitObject(plumbing.NewHash(item))
96
+
if err != nil {
97
+
continue
98
+
}
99
+
commitCount.ByEmail[obj.Author.Email] += 1
100
+
}
101
+
}
102
+
103
+
return commitCount, nil
104
+
}
105
+
106
+
func (g *GitRepo) isDefaultBranch(line PostReceiveLine) (bool, error) {
107
+
defaultBranch, err := g.FindMainBranch()
108
+
if err != nil {
109
+
return false, err
110
+
}
111
+
112
+
refName := plumbing.ReferenceName(line.Ref)
113
+
if refName.IsBranch() {
114
+
return defaultBranch == refName.Short(), nil
115
+
}
116
+
117
+
return false, err
118
+
}
119
+
120
+
func (m RefUpdateMeta) AsRecord() tangled.GitRefUpdate_Meta {
121
+
var byEmail []*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem
122
+
for e, v := range m.CommitCount.ByEmail {
123
+
byEmail = append(byEmail, &tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{
124
+
Email: e,
125
+
Count: int64(v),
126
+
})
127
+
}
128
+
129
+
return tangled.GitRefUpdate_Meta{
130
+
CommitCount: &tangled.GitRefUpdate_Meta_CommitCount{
131
+
ByEmail: byEmail,
132
+
},
133
+
IsDefaultRef: m.IsDefaultRef,
134
+
}
135
+
}
+23
-4
knotserver/internal.go
+23
-4
knotserver/internal.go
···
105
}
106
107
func (h *InternalHandle) insertRefUpdate(line git.PostReceiveLine, gitUserDid, repoDid, repoName string) error {
108
refUpdate := tangled.GitRefUpdate{
109
-
OldSha: line.OldSha,
110
-
NewSha: line.NewSha,
111
Ref: line.Ref,
112
CommitterDid: gitUserDid,
113
RepoDid: repoDid,
114
RepoName: repoName,
115
}
116
eventJson, err := json.Marshal(refUpdate)
117
if err != nil {
···
175
176
trigger := tangled.Pipeline_PushTriggerData{
177
Ref: line.Ref,
178
-
OldSha: line.OldSha,
179
-
NewSha: line.NewSha,
180
}
181
182
compiler := workflow.Compiler{
···
105
}
106
107
func (h *InternalHandle) insertRefUpdate(line git.PostReceiveLine, gitUserDid, repoDid, repoName string) error {
108
+
didSlashRepo, err := securejoin.SecureJoin(repoDid, repoName)
109
+
if err != nil {
110
+
return err
111
+
}
112
+
113
+
repoPath, err := securejoin.SecureJoin(h.c.Repo.ScanPath, didSlashRepo)
114
+
if err != nil {
115
+
return err
116
+
}
117
+
118
+
gr, err := git.PlainOpen(repoPath)
119
+
if err != nil {
120
+
return err
121
+
}
122
+
123
+
meta := gr.RefUpdateMeta(line)
124
+
metaRecord := meta.AsRecord()
125
+
126
refUpdate := tangled.GitRefUpdate{
127
+
OldSha: line.OldSha.String(),
128
+
NewSha: line.NewSha.String(),
129
Ref: line.Ref,
130
CommitterDid: gitUserDid,
131
RepoDid: repoDid,
132
RepoName: repoName,
133
+
Meta: &metaRecord,
134
}
135
eventJson, err := json.Marshal(refUpdate)
136
if err != nil {
···
194
195
trigger := tangled.Pipeline_PushTriggerData{
196
Ref: line.Ref,
197
+
OldSha: line.OldSha.String(),
198
+
NewSha: line.NewSha.String(),
199
}
200
201
compiler := workflow.Compiler{
+39
-1
lexicons/git/refUpdate.json
+39
-1
lexicons/git/refUpdate.json
···
14
"repoDid",
15
"repoName",
16
"oldSha",
17
+
"newSha",
18
+
"meta"
19
],
20
"properties": {
21
"ref": {
···
49
"description": "new SHA of this ref",
50
"minLength": 40,
51
"maxLength": 40
52
+
},
53
+
"meta": {
54
+
"type": "object",
55
+
"required": [
56
+
"isDefaultRef",
57
+
"commitCount"
58
+
],
59
+
"properties": {
60
+
"isDefaultRef": {
61
+
"type": "boolean",
62
+
"default": "false"
63
+
},
64
+
"commitCount": {
65
+
"type": "object",
66
+
"required": [],
67
+
"properties": {
68
+
"byEmail": {
69
+
"type": "array",
70
+
"items": {
71
+
"type": "object",
72
+
"required": [
73
+
"email",
74
+
"count"
75
+
],
76
+
"properties": {
77
+
"email": {
78
+
"type": "string"
79
+
},
80
+
"count": {
81
+
"type": "integer"
82
+
}
83
+
}
84
+
}
85
+
}
86
+
}
87
+
}
88
+
}
89
}
90
}
91
}