Monorepo for Tangled tangled.org

knotserver: fix post-recieve handlers for new gitRefUpdate lexicon

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li fe0f3329 45ed7248

verified
Changed files
+371 -368
api
cmd
knotserver
+338 -338
api/tangled/cbor_gen.go
··· 1202 1203 return nil 1204 } 1205 - func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error { 1206 - if t == nil { 1207 - _, err := w.Write(cbg.CborNull) 1208 - return err 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 - 1222 - // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) 1223 - if len("commitCount") > 1000000 { 1224 - return xerrors.Errorf("Value in field \"commitCount\" was too long") 1225 - } 1226 - 1227 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commitCount"))); err != nil { 1228 - return err 1229 - } 1230 - if _, err := cw.WriteString(string("commitCount")); err != nil { 1231 - return err 1232 - } 1233 - 1234 - if err := t.CommitCount.MarshalCBOR(cw); err != nil { 1235 - return err 1236 - } 1237 - 1238 - // t.IsDefaultRef (bool) (bool) 1239 - if len("isDefaultRef") > 1000000 { 1240 - return xerrors.Errorf("Value in field \"isDefaultRef\" was too long") 1241 - } 1242 - 1243 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("isDefaultRef"))); err != nil { 1244 - return err 1245 - } 1246 - if _, err := cw.WriteString(string("isDefaultRef")); err != nil { 1247 - return err 1248 - } 1249 - 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 - 1275 - func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { 1276 - *t = GitRefUpdate_Meta{} 1277 - 1278 - cr := cbg.NewCborReader(r) 1279 - 1280 - maj, extra, err := cr.ReadHeader() 1281 - if err != nil { 1282 - return err 1283 - } 1284 - defer func() { 1285 - if err == io.EOF { 1286 - err = io.ErrUnexpectedEOF 1287 - } 1288 - }() 1289 - 1290 - if maj != cbg.MajMap { 1291 - return fmt.Errorf("cbor input should be of type map") 1292 - } 1293 - 1294 - if extra > cbg.MaxLength { 1295 - return fmt.Errorf("GitRefUpdate_Meta: map struct too large (%d)", extra) 1296 - } 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 { 1304 - return err 1305 - } 1306 - 1307 - if !ok { 1308 - // Field doesn't exist on this type, so ignore it 1309 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1310 - return err 1311 - } 1312 - continue 1313 - } 1314 - 1315 - switch string(nameBuf[:nameLen]) { 1316 - // t.CommitCount (tangled.GitRefUpdate_Meta_CommitCount) (struct) 1317 - case "commitCount": 1318 - 1319 - { 1320 - 1321 - b, err := cr.ReadByte() 1322 - if err != nil { 1323 - return err 1324 - } 1325 - if b != cbg.CborNull[0] { 1326 - if err := cr.UnreadByte(); err != nil { 1327 - return err 1328 - } 1329 - t.CommitCount = new(GitRefUpdate_Meta_CommitCount) 1330 - if err := t.CommitCount.UnmarshalCBOR(cr); err != nil { 1331 - return xerrors.Errorf("unmarshaling t.CommitCount pointer: %w", err) 1332 - } 1333 - } 1334 - 1335 - } 1336 - // t.IsDefaultRef (bool) (bool) 1337 - case "isDefaultRef": 1338 - 1339 - maj, extra, err = cr.ReadHeader() 1340 - if err != nil { 1341 - return err 1342 - } 1343 - if maj != cbg.MajOther { 1344 - return fmt.Errorf("booleans must be major type 7") 1345 - } 1346 - switch extra { 1347 - case 20: 1348 - t.IsDefaultRef = false 1349 - case 21: 1350 - t.IsDefaultRef = true 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 1377 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1378 - return err 1379 - } 1380 - } 1381 - } 1382 - 1383 - return nil 1384 - } 1385 - func (t *GitRefUpdate_Meta_CommitCount) MarshalCBOR(w io.Writer) error { 1386 if t == nil { 1387 _, err := w.Write(cbg.CborNull) 1388 return err ··· 1399 return err 1400 } 1401 1402 - // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 1403 if t.ByEmail != nil { 1404 1405 if len("byEmail") > 1000000 { ··· 1430 return nil 1431 } 1432 1433 - func (t *GitRefUpdate_Meta_CommitCount) UnmarshalCBOR(r io.Reader) (err error) { 1434 - *t = GitRefUpdate_Meta_CommitCount{} 1435 1436 cr := cbg.NewCborReader(r) 1437 ··· 1450 } 1451 1452 if extra > cbg.MaxLength { 1453 - return fmt.Errorf("GitRefUpdate_Meta_CommitCount: map struct too large (%d)", extra) 1454 } 1455 1456 n := extra ··· 1471 } 1472 1473 switch string(nameBuf[:nameLen]) { 1474 - // t.ByEmail ([]*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem) (slice) 1475 case "byEmail": 1476 1477 maj, extra, err = cr.ReadHeader() ··· 1488 } 1489 1490 if extra > 0 { 1491 - t.ByEmail = make([]*GitRefUpdate_Meta_CommitCount_ByEmail_Elem, extra) 1492 } 1493 1494 for i := 0; i < int(extra); i++ { ··· 1510 if err := cr.UnreadByte(); err != nil { 1511 return err 1512 } 1513 - t.ByEmail[i] = new(GitRefUpdate_Meta_CommitCount_ByEmail_Elem) 1514 if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil { 1515 return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err) 1516 } ··· 1531 1532 return nil 1533 } 1534 - func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) MarshalCBOR(w io.Writer) error { 1535 if t == nil { 1536 _, err := w.Write(cbg.CborNull) 1537 return err ··· 1590 return nil 1591 } 1592 1593 - func (t *GitRefUpdate_Meta_CommitCount_ByEmail_Elem) UnmarshalCBOR(r io.Reader) (err error) { 1594 - *t = GitRefUpdate_Meta_CommitCount_ByEmail_Elem{} 1595 1596 cr := cbg.NewCborReader(r) 1597 ··· 1610 } 1611 1612 if extra > cbg.MaxLength { 1613 - return fmt.Errorf("GitRefUpdate_Meta_CommitCount_ByEmail_Elem: map struct too large (%d)", extra) 1614 } 1615 1616 n := extra ··· 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 ··· 1696 return err 1697 } 1698 1699 - // t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice) 1700 if t.Inputs != nil { 1701 1702 if len("inputs") > 1000000 { ··· 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 ··· 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 ··· 1768 } 1769 1770 switch string(nameBuf[:nameLen]) { 1771 - // t.Inputs ([]*tangled.GitRefUpdate_Pair) (slice) 1772 case "inputs": 1773 1774 maj, extra, err = cr.ReadHeader() ··· 1785 } 1786 1787 if extra > 0 { 1788 - t.Inputs = make([]*GitRefUpdate_Pair, extra) 1789 } 1790 1791 for i := 0; i < int(extra); i++ { ··· 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 } ··· 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 ··· 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 ··· 1908 } 1909 1910 if extra > cbg.MaxLength { 1911 - return fmt.Errorf("GitRefUpdate_Pair: map struct too large (%d)", extra) 1912 } 1913 1914 n := extra ··· 1965 } 1966 1967 t.Size = int64(extraI) 1968 } 1969 1970 default: ··· 6522 6523 return nil 6524 } 6525 - func (t *RepoPull_Target) MarshalCBOR(w io.Writer) error { 6526 - if t == nil { 6527 - _, err := w.Write(cbg.CborNull) 6528 - return err 6529 - } 6530 - 6531 - cw := cbg.NewCborWriter(w) 6532 - 6533 - if _, err := cw.Write([]byte{162}); err != nil { 6534 - return err 6535 - } 6536 - 6537 - // t.Repo (string) (string) 6538 - if len("repo") > 1000000 { 6539 - return xerrors.Errorf("Value in field \"repo\" was too long") 6540 - } 6541 - 6542 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 6543 - return err 6544 - } 6545 - if _, err := cw.WriteString(string("repo")); err != nil { 6546 - return err 6547 - } 6548 - 6549 - if len(t.Repo) > 1000000 { 6550 - return xerrors.Errorf("Value in field t.Repo was too long") 6551 - } 6552 - 6553 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { 6554 - return err 6555 - } 6556 - if _, err := cw.WriteString(string(t.Repo)); err != nil { 6557 - return err 6558 - } 6559 - 6560 - // t.Branch (string) (string) 6561 - if len("branch") > 1000000 { 6562 - return xerrors.Errorf("Value in field \"branch\" was too long") 6563 - } 6564 - 6565 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("branch"))); err != nil { 6566 - return err 6567 - } 6568 - if _, err := cw.WriteString(string("branch")); err != nil { 6569 - return err 6570 - } 6571 - 6572 - if len(t.Branch) > 1000000 { 6573 - return xerrors.Errorf("Value in field t.Branch was too long") 6574 - } 6575 - 6576 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Branch))); err != nil { 6577 - return err 6578 - } 6579 - if _, err := cw.WriteString(string(t.Branch)); err != nil { 6580 - return err 6581 - } 6582 - return nil 6583 - } 6584 - 6585 - func (t *RepoPull_Target) UnmarshalCBOR(r io.Reader) (err error) { 6586 - *t = RepoPull_Target{} 6587 - 6588 - cr := cbg.NewCborReader(r) 6589 - 6590 - maj, extra, err := cr.ReadHeader() 6591 - if err != nil { 6592 - return err 6593 - } 6594 - defer func() { 6595 - if err == io.EOF { 6596 - err = io.ErrUnexpectedEOF 6597 - } 6598 - }() 6599 - 6600 - if maj != cbg.MajMap { 6601 - return fmt.Errorf("cbor input should be of type map") 6602 - } 6603 - 6604 - if extra > cbg.MaxLength { 6605 - return fmt.Errorf("RepoPull_Target: map struct too large (%d)", extra) 6606 - } 6607 - 6608 - n := extra 6609 - 6610 - nameBuf := make([]byte, 6) 6611 - for i := uint64(0); i < n; i++ { 6612 - nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 6613 - if err != nil { 6614 - return err 6615 - } 6616 - 6617 - if !ok { 6618 - // Field doesn't exist on this type, so ignore it 6619 - if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 6620 - return err 6621 - } 6622 - continue 6623 - } 6624 - 6625 - switch string(nameBuf[:nameLen]) { 6626 - // t.Repo (string) (string) 6627 - case "repo": 6628 - 6629 - { 6630 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 6631 - if err != nil { 6632 - return err 6633 - } 6634 - 6635 - t.Repo = string(sval) 6636 - } 6637 - // t.Branch (string) (string) 6638 - case "branch": 6639 - 6640 - { 6641 - sval, err := cbg.ReadStringWithMax(cr, 1000000) 6642 - if err != nil { 6643 - return err 6644 - } 6645 - 6646 - t.Branch = string(sval) 6647 - } 6648 - 6649 - default: 6650 - // Field doesn't exist on this type, so ignore it 6651 - if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 6652 - return err 6653 - } 6654 - } 6655 - } 6656 - 6657 - return nil 6658 - } 6659 func (t *RepoPull) MarshalCBOR(w io.Writer) error { 6660 if t == nil { 6661 _, err := w.Write(cbg.CborNull) ··· 7533 } 7534 7535 t.Status = string(sval) 7536 } 7537 7538 default:
··· 1202 1203 return nil 1204 } 1205 + func (t *GitRefUpdate_CommitCountBreakdown) MarshalCBOR(w io.Writer) error { 1206 if t == nil { 1207 _, err := w.Write(cbg.CborNull) 1208 return err ··· 1219 return err 1220 } 1221 1222 + // t.ByEmail ([]*tangled.GitRefUpdate_IndividualEmailCommitCount) (slice) 1223 if t.ByEmail != nil { 1224 1225 if len("byEmail") > 1000000 { ··· 1250 return nil 1251 } 1252 1253 + func (t *GitRefUpdate_CommitCountBreakdown) UnmarshalCBOR(r io.Reader) (err error) { 1254 + *t = GitRefUpdate_CommitCountBreakdown{} 1255 1256 cr := cbg.NewCborReader(r) 1257 ··· 1270 } 1271 1272 if extra > cbg.MaxLength { 1273 + return fmt.Errorf("GitRefUpdate_CommitCountBreakdown: map struct too large (%d)", extra) 1274 } 1275 1276 n := extra ··· 1291 } 1292 1293 switch string(nameBuf[:nameLen]) { 1294 + // t.ByEmail ([]*tangled.GitRefUpdate_IndividualEmailCommitCount) (slice) 1295 case "byEmail": 1296 1297 maj, extra, err = cr.ReadHeader() ··· 1308 } 1309 1310 if extra > 0 { 1311 + t.ByEmail = make([]*GitRefUpdate_IndividualEmailCommitCount, extra) 1312 } 1313 1314 for i := 0; i < int(extra); i++ { ··· 1330 if err := cr.UnreadByte(); err != nil { 1331 return err 1332 } 1333 + t.ByEmail[i] = new(GitRefUpdate_IndividualEmailCommitCount) 1334 if err := t.ByEmail[i].UnmarshalCBOR(cr); err != nil { 1335 return xerrors.Errorf("unmarshaling t.ByEmail[i] pointer: %w", err) 1336 } ··· 1351 1352 return nil 1353 } 1354 + func (t *GitRefUpdate_IndividualEmailCommitCount) MarshalCBOR(w io.Writer) error { 1355 if t == nil { 1356 _, err := w.Write(cbg.CborNull) 1357 return err ··· 1410 return nil 1411 } 1412 1413 + func (t *GitRefUpdate_IndividualEmailCommitCount) UnmarshalCBOR(r io.Reader) (err error) { 1414 + *t = GitRefUpdate_IndividualEmailCommitCount{} 1415 1416 cr := cbg.NewCborReader(r) 1417 ··· 1430 } 1431 1432 if extra > cbg.MaxLength { 1433 + return fmt.Errorf("GitRefUpdate_IndividualEmailCommitCount: map struct too large (%d)", extra) 1434 } 1435 1436 n := extra ··· 1499 1500 return nil 1501 } 1502 + func (t *GitRefUpdate_LangBreakdown) MarshalCBOR(w io.Writer) error { 1503 if t == nil { 1504 _, err := w.Write(cbg.CborNull) 1505 return err ··· 1516 return err 1517 } 1518 1519 + // t.Inputs ([]*tangled.GitRefUpdate_IndividualLanguageSize) (slice) 1520 if t.Inputs != nil { 1521 1522 if len("inputs") > 1000000 { ··· 1547 return nil 1548 } 1549 1550 + func (t *GitRefUpdate_LangBreakdown) UnmarshalCBOR(r io.Reader) (err error) { 1551 + *t = GitRefUpdate_LangBreakdown{} 1552 1553 cr := cbg.NewCborReader(r) 1554 ··· 1567 } 1568 1569 if extra > cbg.MaxLength { 1570 + return fmt.Errorf("GitRefUpdate_LangBreakdown: map struct too large (%d)", extra) 1571 } 1572 1573 n := extra ··· 1588 } 1589 1590 switch string(nameBuf[:nameLen]) { 1591 + // t.Inputs ([]*tangled.GitRefUpdate_IndividualLanguageSize) (slice) 1592 case "inputs": 1593 1594 maj, extra, err = cr.ReadHeader() ··· 1605 } 1606 1607 if extra > 0 { 1608 + t.Inputs = make([]*GitRefUpdate_IndividualLanguageSize, extra) 1609 } 1610 1611 for i := 0; i < int(extra); i++ { ··· 1627 if err := cr.UnreadByte(); err != nil { 1628 return err 1629 } 1630 + t.Inputs[i] = new(GitRefUpdate_IndividualLanguageSize) 1631 if err := t.Inputs[i].UnmarshalCBOR(cr); err != nil { 1632 return xerrors.Errorf("unmarshaling t.Inputs[i] pointer: %w", err) 1633 } ··· 1648 1649 return nil 1650 } 1651 + func (t *GitRefUpdate_IndividualLanguageSize) MarshalCBOR(w io.Writer) error { 1652 if t == nil { 1653 _, err := w.Write(cbg.CborNull) 1654 return err ··· 1708 return nil 1709 } 1710 1711 + func (t *GitRefUpdate_IndividualLanguageSize) UnmarshalCBOR(r io.Reader) (err error) { 1712 + *t = GitRefUpdate_IndividualLanguageSize{} 1713 1714 cr := cbg.NewCborReader(r) 1715 ··· 1728 } 1729 1730 if extra > cbg.MaxLength { 1731 + return fmt.Errorf("GitRefUpdate_IndividualLanguageSize: map struct too large (%d)", extra) 1732 } 1733 1734 n := extra ··· 1785 } 1786 1787 t.Size = int64(extraI) 1788 + } 1789 + 1790 + default: 1791 + // Field doesn't exist on this type, so ignore it 1792 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 1793 + return err 1794 + } 1795 + } 1796 + } 1797 + 1798 + return nil 1799 + } 1800 + func (t *GitRefUpdate_Meta) MarshalCBOR(w io.Writer) error { 1801 + if t == nil { 1802 + _, err := w.Write(cbg.CborNull) 1803 + return err 1804 + } 1805 + 1806 + cw := cbg.NewCborWriter(w) 1807 + fieldCount := 3 1808 + 1809 + if t.LangBreakdown == nil { 1810 + fieldCount-- 1811 + } 1812 + 1813 + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { 1814 + return err 1815 + } 1816 + 1817 + // t.CommitCount (tangled.GitRefUpdate_CommitCountBreakdown) (struct) 1818 + if len("commitCount") > 1000000 { 1819 + return xerrors.Errorf("Value in field \"commitCount\" was too long") 1820 + } 1821 + 1822 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("commitCount"))); err != nil { 1823 + return err 1824 + } 1825 + if _, err := cw.WriteString(string("commitCount")); err != nil { 1826 + return err 1827 + } 1828 + 1829 + if err := t.CommitCount.MarshalCBOR(cw); err != nil { 1830 + return err 1831 + } 1832 + 1833 + // t.IsDefaultRef (bool) (bool) 1834 + if len("isDefaultRef") > 1000000 { 1835 + return xerrors.Errorf("Value in field \"isDefaultRef\" was too long") 1836 + } 1837 + 1838 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("isDefaultRef"))); err != nil { 1839 + return err 1840 + } 1841 + if _, err := cw.WriteString(string("isDefaultRef")); err != nil { 1842 + return err 1843 + } 1844 + 1845 + if err := cbg.WriteBool(w, t.IsDefaultRef); err != nil { 1846 + return err 1847 + } 1848 + 1849 + // t.LangBreakdown (tangled.GitRefUpdate_LangBreakdown) (struct) 1850 + if t.LangBreakdown != nil { 1851 + 1852 + if len("langBreakdown") > 1000000 { 1853 + return xerrors.Errorf("Value in field \"langBreakdown\" was too long") 1854 + } 1855 + 1856 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("langBreakdown"))); err != nil { 1857 + return err 1858 + } 1859 + if _, err := cw.WriteString(string("langBreakdown")); err != nil { 1860 + return err 1861 + } 1862 + 1863 + if err := t.LangBreakdown.MarshalCBOR(cw); err != nil { 1864 + return err 1865 + } 1866 + } 1867 + return nil 1868 + } 1869 + 1870 + func (t *GitRefUpdate_Meta) UnmarshalCBOR(r io.Reader) (err error) { 1871 + *t = GitRefUpdate_Meta{} 1872 + 1873 + cr := cbg.NewCborReader(r) 1874 + 1875 + maj, extra, err := cr.ReadHeader() 1876 + if err != nil { 1877 + return err 1878 + } 1879 + defer func() { 1880 + if err == io.EOF { 1881 + err = io.ErrUnexpectedEOF 1882 + } 1883 + }() 1884 + 1885 + if maj != cbg.MajMap { 1886 + return fmt.Errorf("cbor input should be of type map") 1887 + } 1888 + 1889 + if extra > cbg.MaxLength { 1890 + return fmt.Errorf("GitRefUpdate_Meta: map struct too large (%d)", extra) 1891 + } 1892 + 1893 + n := extra 1894 + 1895 + nameBuf := make([]byte, 13) 1896 + for i := uint64(0); i < n; i++ { 1897 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 1898 + if err != nil { 1899 + return err 1900 + } 1901 + 1902 + if !ok { 1903 + // Field doesn't exist on this type, so ignore it 1904 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 1905 + return err 1906 + } 1907 + continue 1908 + } 1909 + 1910 + switch string(nameBuf[:nameLen]) { 1911 + // t.CommitCount (tangled.GitRefUpdate_CommitCountBreakdown) (struct) 1912 + case "commitCount": 1913 + 1914 + { 1915 + 1916 + b, err := cr.ReadByte() 1917 + if err != nil { 1918 + return err 1919 + } 1920 + if b != cbg.CborNull[0] { 1921 + if err := cr.UnreadByte(); err != nil { 1922 + return err 1923 + } 1924 + t.CommitCount = new(GitRefUpdate_CommitCountBreakdown) 1925 + if err := t.CommitCount.UnmarshalCBOR(cr); err != nil { 1926 + return xerrors.Errorf("unmarshaling t.CommitCount pointer: %w", err) 1927 + } 1928 + } 1929 + 1930 + } 1931 + // t.IsDefaultRef (bool) (bool) 1932 + case "isDefaultRef": 1933 + 1934 + maj, extra, err = cr.ReadHeader() 1935 + if err != nil { 1936 + return err 1937 + } 1938 + if maj != cbg.MajOther { 1939 + return fmt.Errorf("booleans must be major type 7") 1940 + } 1941 + switch extra { 1942 + case 20: 1943 + t.IsDefaultRef = false 1944 + case 21: 1945 + t.IsDefaultRef = true 1946 + default: 1947 + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) 1948 + } 1949 + // t.LangBreakdown (tangled.GitRefUpdate_LangBreakdown) (struct) 1950 + case "langBreakdown": 1951 + 1952 + { 1953 + 1954 + b, err := cr.ReadByte() 1955 + if err != nil { 1956 + return err 1957 + } 1958 + if b != cbg.CborNull[0] { 1959 + if err := cr.UnreadByte(); err != nil { 1960 + return err 1961 + } 1962 + t.LangBreakdown = new(GitRefUpdate_LangBreakdown) 1963 + if err := t.LangBreakdown.UnmarshalCBOR(cr); err != nil { 1964 + return xerrors.Errorf("unmarshaling t.LangBreakdown pointer: %w", err) 1965 + } 1966 + } 1967 + 1968 } 1969 1970 default: ··· 6522 6523 return nil 6524 } 6525 func (t *RepoPull) MarshalCBOR(w io.Writer) error { 6526 if t == nil { 6527 _, err := w.Write(cbg.CborNull) ··· 7399 } 7400 7401 t.Status = string(sval) 7402 + } 7403 + 7404 + default: 7405 + // Field doesn't exist on this type, so ignore it 7406 + if err := cbg.ScanForLinks(r, func(cid.Cid) {}); err != nil { 7407 + return err 7408 + } 7409 + } 7410 + } 7411 + 7412 + return nil 7413 + } 7414 + func (t *RepoPull_Target) MarshalCBOR(w io.Writer) error { 7415 + if t == nil { 7416 + _, err := w.Write(cbg.CborNull) 7417 + return err 7418 + } 7419 + 7420 + cw := cbg.NewCborWriter(w) 7421 + 7422 + if _, err := cw.Write([]byte{162}); err != nil { 7423 + return err 7424 + } 7425 + 7426 + // t.Repo (string) (string) 7427 + if len("repo") > 1000000 { 7428 + return xerrors.Errorf("Value in field \"repo\" was too long") 7429 + } 7430 + 7431 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("repo"))); err != nil { 7432 + return err 7433 + } 7434 + if _, err := cw.WriteString(string("repo")); err != nil { 7435 + return err 7436 + } 7437 + 7438 + if len(t.Repo) > 1000000 { 7439 + return xerrors.Errorf("Value in field t.Repo was too long") 7440 + } 7441 + 7442 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Repo))); err != nil { 7443 + return err 7444 + } 7445 + if _, err := cw.WriteString(string(t.Repo)); err != nil { 7446 + return err 7447 + } 7448 + 7449 + // t.Branch (string) (string) 7450 + if len("branch") > 1000000 { 7451 + return xerrors.Errorf("Value in field \"branch\" was too long") 7452 + } 7453 + 7454 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("branch"))); err != nil { 7455 + return err 7456 + } 7457 + if _, err := cw.WriteString(string("branch")); err != nil { 7458 + return err 7459 + } 7460 + 7461 + if len(t.Branch) > 1000000 { 7462 + return xerrors.Errorf("Value in field t.Branch was too long") 7463 + } 7464 + 7465 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.Branch))); err != nil { 7466 + return err 7467 + } 7468 + if _, err := cw.WriteString(string(t.Branch)); err != nil { 7469 + return err 7470 + } 7471 + return nil 7472 + } 7473 + 7474 + func (t *RepoPull_Target) UnmarshalCBOR(r io.Reader) (err error) { 7475 + *t = RepoPull_Target{} 7476 + 7477 + cr := cbg.NewCborReader(r) 7478 + 7479 + maj, extra, err := cr.ReadHeader() 7480 + if err != nil { 7481 + return err 7482 + } 7483 + defer func() { 7484 + if err == io.EOF { 7485 + err = io.ErrUnexpectedEOF 7486 + } 7487 + }() 7488 + 7489 + if maj != cbg.MajMap { 7490 + return fmt.Errorf("cbor input should be of type map") 7491 + } 7492 + 7493 + if extra > cbg.MaxLength { 7494 + return fmt.Errorf("RepoPull_Target: map struct too large (%d)", extra) 7495 + } 7496 + 7497 + n := extra 7498 + 7499 + nameBuf := make([]byte, 6) 7500 + for i := uint64(0); i < n; i++ { 7501 + nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 7502 + if err != nil { 7503 + return err 7504 + } 7505 + 7506 + if !ok { 7507 + // Field doesn't exist on this type, so ignore it 7508 + if err := cbg.ScanForLinks(cr, func(cid.Cid) {}); err != nil { 7509 + return err 7510 + } 7511 + continue 7512 + } 7513 + 7514 + switch string(nameBuf[:nameLen]) { 7515 + // t.Repo (string) (string) 7516 + case "repo": 7517 + 7518 + { 7519 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 7520 + if err != nil { 7521 + return err 7522 + } 7523 + 7524 + t.Repo = string(sval) 7525 + } 7526 + // t.Branch (string) (string) 7527 + case "branch": 7528 + 7529 + { 7530 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 7531 + if err != nil { 7532 + return err 7533 + } 7534 + 7535 + t.Branch = string(sval) 7536 } 7537 7538 default:
+19 -15
api/tangled/gitrefUpdate.go
··· 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 - LangBreakdown *GitRefUpdate_Meta_LangBreakdown `json:"langBreakdown,omitempty" cborgen:"langBreakdown,omitempty"` 40 } 41 42 - type GitRefUpdate_Meta_CommitCount struct { 43 - ByEmail []*GitRefUpdate_Meta_CommitCount_ByEmail_Elem `json:"byEmail,omitempty" cborgen:"byEmail,omitempty"` 44 - } 45 - 46 - type GitRefUpdate_Meta_CommitCount_ByEmail_Elem 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 }
··· 33 RepoName string `json:"repoName" cborgen:"repoName"` 34 } 35 36 + // GitRefUpdate_CommitCountBreakdown is a "commitCountBreakdown" in the sh.tangled.git.refUpdate schema. 37 + type GitRefUpdate_CommitCountBreakdown struct { 38 + ByEmail []*GitRefUpdate_IndividualEmailCommitCount `json:"byEmail,omitempty" cborgen:"byEmail,omitempty"` 39 } 40 41 + // GitRefUpdate_IndividualEmailCommitCount is a "individualEmailCommitCount" in the sh.tangled.git.refUpdate schema. 42 + type GitRefUpdate_IndividualEmailCommitCount struct { 43 Count int64 `json:"count" cborgen:"count"` 44 Email string `json:"email" cborgen:"email"` 45 } 46 47 + // GitRefUpdate_IndividualLanguageSize is a "individualLanguageSize" in the sh.tangled.git.refUpdate schema. 48 + type GitRefUpdate_IndividualLanguageSize struct { 49 Lang string `json:"lang" cborgen:"lang"` 50 Size int64 `json:"size" cborgen:"size"` 51 } 52 + 53 + // GitRefUpdate_LangBreakdown is a "langBreakdown" in the sh.tangled.git.refUpdate schema. 54 + type GitRefUpdate_LangBreakdown struct { 55 + Inputs []*GitRefUpdate_IndividualLanguageSize `json:"inputs,omitempty" cborgen:"inputs,omitempty"` 56 + } 57 + 58 + // GitRefUpdate_Meta is a "meta" in the sh.tangled.git.refUpdate schema. 59 + type GitRefUpdate_Meta struct { 60 + CommitCount *GitRefUpdate_CommitCountBreakdown `json:"commitCount" cborgen:"commitCount"` 61 + IsDefaultRef bool `json:"isDefaultRef" cborgen:"isDefaultRef"` 62 + LangBreakdown *GitRefUpdate_LangBreakdown `json:"langBreakdown,omitempty" cborgen:"langBreakdown,omitempty"` 63 + }
+5 -5
cmd/gen.go
··· 18 tangled.FeedReaction{}, 19 tangled.FeedStar{}, 20 tangled.GitRefUpdate{}, 21 tangled.GitRefUpdate_Meta{}, 22 - tangled.GitRefUpdate_Meta_CommitCount{}, 23 - tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{}, 24 - tangled.GitRefUpdate_Meta_LangBreakdown{}, 25 - tangled.GitRefUpdate_Pair{}, 26 tangled.GraphFollow{}, 27 tangled.Knot{}, 28 tangled.KnotMember{}, ··· 46 tangled.RepoPull{}, 47 tangled.RepoPullComment{}, 48 tangled.RepoPull_Source{}, 49 - tangled.RepoPull_Target{}, 50 tangled.RepoPullStatus{}, 51 tangled.Spindle{}, 52 tangled.SpindleMember{}, 53 tangled.String{},
··· 18 tangled.FeedReaction{}, 19 tangled.FeedStar{}, 20 tangled.GitRefUpdate{}, 21 + tangled.GitRefUpdate_CommitCountBreakdown{}, 22 + tangled.GitRefUpdate_IndividualEmailCommitCount{}, 23 + tangled.GitRefUpdate_LangBreakdown{}, 24 + tangled.GitRefUpdate_IndividualLanguageSize{}, 25 tangled.GitRefUpdate_Meta{}, 26 tangled.GraphFollow{}, 27 tangled.Knot{}, 28 tangled.KnotMember{}, ··· 46 tangled.RepoPull{}, 47 tangled.RepoPullComment{}, 48 tangled.RepoPull_Source{}, 49 tangled.RepoPullStatus{}, 50 + tangled.RepoPull_Target{}, 51 tangled.Spindle{}, 52 tangled.SpindleMember{}, 53 tangled.String{},
+9 -10
knotserver/git/post_receive.go
··· 145 } 146 147 func (m RefUpdateMeta) AsRecord() tangled.GitRefUpdate_Meta { 148 - var byEmail []*tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem 149 for e, v := range m.CommitCount.ByEmail { 150 - byEmail = append(byEmail, &tangled.GitRefUpdate_Meta_CommitCount_ByEmail_Elem{ 151 Email: e, 152 Count: int64(v), 153 }) 154 } 155 156 - var langs []*tangled.GitRefUpdate_Pair 157 for lang, size := range m.LangBreakdown { 158 - langs = append(langs, &tangled.GitRefUpdate_Pair{ 159 Lang: lang, 160 Size: size, 161 }) 162 } 163 - langBreakdown := &tangled.GitRefUpdate_Meta_LangBreakdown{ 164 - Inputs: langs, 165 - } 166 167 return tangled.GitRefUpdate_Meta{ 168 - CommitCount: &tangled.GitRefUpdate_Meta_CommitCount{ 169 ByEmail: byEmail, 170 }, 171 - IsDefaultRef: m.IsDefaultRef, 172 - LangBreakdown: langBreakdown, 173 } 174 }
··· 145 } 146 147 func (m RefUpdateMeta) AsRecord() tangled.GitRefUpdate_Meta { 148 + var byEmail []*tangled.GitRefUpdate_IndividualEmailCommitCount 149 for e, v := range m.CommitCount.ByEmail { 150 + byEmail = append(byEmail, &tangled.GitRefUpdate_IndividualEmailCommitCount{ 151 Email: e, 152 Count: int64(v), 153 }) 154 } 155 156 + var langs []*tangled.GitRefUpdate_IndividualLanguageSize 157 for lang, size := range m.LangBreakdown { 158 + langs = append(langs, &tangled.GitRefUpdate_IndividualLanguageSize{ 159 Lang: lang, 160 Size: size, 161 }) 162 } 163 164 return tangled.GitRefUpdate_Meta{ 165 + CommitCount: &tangled.GitRefUpdate_CommitCountBreakdown{ 166 ByEmail: byEmail, 167 }, 168 + IsDefaultRef: m.IsDefaultRef, 169 + LangBreakdown: &tangled.GitRefUpdate_LangBreakdown{ 170 + Inputs: langs, 171 + }, 172 } 173 }