forked from tangled.org/core
Monorepo for Tangled

appview: refactor lexicon setup and simplify

Can't use sh.tangled.repo.pull.state.{open,closed,merged} since
that results in a stateopen.go -- overwriting issue.state.open etc.
Hence, it's pull.status.

authored by anirudh.fi and committed by oppi.li 45bc4364 0506ef79

+64 -30
api/tangled/cbor_gen.go
··· 2059 2059 2060 2060 return nil 2061 2061 } 2062 - func (t *RepoPullPatch) MarshalCBOR(w io.Writer) error { 2062 + func (t *RepoPull) MarshalCBOR(w io.Writer) error { 2063 2063 if t == nil { 2064 2064 _, err := w.Write(cbg.CborNull) 2065 2065 return err 2066 2066 } 2067 2067 2068 2068 cw := cbg.NewCborWriter(w) 2069 - fieldCount := 8 2069 + fieldCount := 9 2070 2070 2071 2071 if t.Body == nil { 2072 2072 fieldCount-- ··· 2128 2128 return err 2129 2129 } 2130 2130 2131 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.patch"))); err != nil { 2131 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil { 2132 2132 return err 2133 2133 } 2134 - if _, err := cw.WriteString(string("sh.tangled.repo.pull.patch")); err != nil { 2134 + if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil { 2135 2135 return err 2136 2136 } 2137 2137 ··· 2289 2289 if _, err := cw.WriteString(string(t.TargetRepo)); err != nil { 2290 2290 return err 2291 2291 } 2292 + 2293 + // t.TargetBranch (string) (string) 2294 + if len("targetBranch") > 1000000 { 2295 + return xerrors.Errorf("Value in field \"targetBranch\" was too long") 2296 + } 2297 + 2298 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil { 2299 + return err 2300 + } 2301 + if _, err := cw.WriteString(string("targetBranch")); err != nil { 2302 + return err 2303 + } 2304 + 2305 + if len(t.TargetBranch) > 1000000 { 2306 + return xerrors.Errorf("Value in field t.TargetBranch was too long") 2307 + } 2308 + 2309 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil { 2310 + return err 2311 + } 2312 + if _, err := cw.WriteString(string(t.TargetBranch)); err != nil { 2313 + return err 2314 + } 2292 2315 return nil 2293 2316 } 2294 2317 2295 - func (t *RepoPullPatch) UnmarshalCBOR(r io.Reader) (err error) { 2296 - *t = RepoPullPatch{} 2318 + func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) { 2319 + *t = RepoPull{} 2297 2320 2298 2321 cr := cbg.NewCborReader(r) 2299 2322 ··· 2312 2335 } 2313 2336 2314 2337 if extra > cbg.MaxLength { 2315 - return fmt.Errorf("RepoPullPatch: map struct too large (%d)", extra) 2338 + return fmt.Errorf("RepoPull: map struct too large (%d)", extra) 2316 2339 } 2317 2340 2318 2341 n := extra 2319 2342 2320 - nameBuf := make([]byte, 10) 2343 + nameBuf := make([]byte, 12) 2321 2344 for i := uint64(0); i < n; i++ { 2322 2345 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2323 2346 if err != nil { ··· 2466 2489 2467 2490 t.TargetRepo = string(sval) 2468 2491 } 2492 + // t.TargetBranch (string) (string) 2493 + case "targetBranch": 2494 + 2495 + { 2496 + sval, err := cbg.ReadStringWithMax(cr, 1000000) 2497 + if err != nil { 2498 + return err 2499 + } 2500 + 2501 + t.TargetBranch = string(sval) 2502 + } 2469 2503 2470 2504 default: 2471 2505 // Field doesn't exist on this type, so ignore it ··· 2477 2511 2478 2512 return nil 2479 2513 } 2480 - func (t *RepoPullState) MarshalCBOR(w io.Writer) error { 2514 + func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error { 2481 2515 if t == nil { 2482 2516 _, err := w.Write(cbg.CborNull) 2483 2517 return err ··· 2486 2520 cw := cbg.NewCborWriter(w) 2487 2521 fieldCount := 3 2488 2522 2489 - if t.State == nil { 2523 + if t.Status == nil { 2490 2524 fieldCount-- 2491 2525 } 2492 2526 ··· 2529 2563 return err 2530 2564 } 2531 2565 2532 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.state"))); err != nil { 2566 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil { 2533 2567 return err 2534 2568 } 2535 - if _, err := cw.WriteString(string("sh.tangled.repo.pull.state")); err != nil { 2569 + if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil { 2536 2570 return err 2537 2571 } 2538 2572 2539 - // t.State (string) (string) 2540 - if t.State != nil { 2573 + // t.Status (string) (string) 2574 + if t.Status != nil { 2541 2575 2542 - if len("state") > 1000000 { 2543 - return xerrors.Errorf("Value in field \"state\" was too long") 2576 + if len("status") > 1000000 { 2577 + return xerrors.Errorf("Value in field \"status\" was too long") 2544 2578 } 2545 2579 2546 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil { 2580 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil { 2547 2581 return err 2548 2582 } 2549 - if _, err := cw.WriteString(string("state")); err != nil { 2583 + if _, err := cw.WriteString(string("status")); err != nil { 2550 2584 return err 2551 2585 } 2552 2586 2553 - if t.State == nil { 2587 + if t.Status == nil { 2554 2588 if _, err := cw.Write(cbg.CborNull); err != nil { 2555 2589 return err 2556 2590 } 2557 2591 } else { 2558 - if len(*t.State) > 1000000 { 2559 - return xerrors.Errorf("Value in field t.State was too long") 2592 + if len(*t.Status) > 1000000 { 2593 + return xerrors.Errorf("Value in field t.Status was too long") 2560 2594 } 2561 2595 2562 - if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.State))); err != nil { 2596 + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Status))); err != nil { 2563 2597 return err 2564 2598 } 2565 - if _, err := cw.WriteString(string(*t.State)); err != nil { 2599 + if _, err := cw.WriteString(string(*t.Status)); err != nil { 2566 2600 return err 2567 2601 } 2568 2602 } ··· 2570 2604 return nil 2571 2605 } 2572 2606 2573 - func (t *RepoPullState) UnmarshalCBOR(r io.Reader) (err error) { 2574 - *t = RepoPullState{} 2607 + func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) { 2608 + *t = RepoPullStatus{} 2575 2609 2576 2610 cr := cbg.NewCborReader(r) 2577 2611 ··· 2590 2624 } 2591 2625 2592 2626 if extra > cbg.MaxLength { 2593 - return fmt.Errorf("RepoPullState: map struct too large (%d)", extra) 2627 + return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra) 2594 2628 } 2595 2629 2596 2630 n := extra 2597 2631 2598 - nameBuf := make([]byte, 5) 2632 + nameBuf := make([]byte, 6) 2599 2633 for i := uint64(0); i < n; i++ { 2600 2634 nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000) 2601 2635 if err != nil { ··· 2633 2667 2634 2668 t.LexiconTypeID = string(sval) 2635 2669 } 2636 - // t.State (string) (string) 2637 - case "state": 2670 + // t.Status (string) (string) 2671 + case "status": 2638 2672 2639 2673 { 2640 2674 b, err := cr.ReadByte() ··· 2651 2685 return err 2652 2686 } 2653 2687 2654 - t.State = (*string)(&sval) 2688 + t.Status = (*string)(&sval) 2655 2689 } 2656 2690 } 2657 2691
+2 -2
api/tangled/pullcomment.go
··· 5 5 // schema: sh.tangled.repo.pull.comment 6 6 7 7 import ( 8 - //"github.com/bluesky-social/indigo/lex/util" 8 + "github.com/bluesky-social/indigo/lex/util" 9 9 ) 10 10 11 11 const ( ··· 13 13 ) 14 14 15 15 func init() { 16 - //util.RegisterType("sh.tangled.repo.pull.comment", &RepoPullComment{}) 16 + util.RegisterType("sh.tangled.repo.pull.comment", &RepoPullComment{}) 17 17 } // 18 18 // RECORDTYPE: RepoPullComment 19 19 type RepoPullComment struct {
+7 -6
api/tangled/pullpatch.go api/tangled/repopull.go
··· 2 2 3 3 package tangled 4 4 5 - // schema: sh.tangled.repo.pull.patch 5 + // schema: sh.tangled.repo.pull 6 6 7 7 import ( 8 8 "github.com/bluesky-social/indigo/lex/util" 9 9 ) 10 10 11 11 const ( 12 - RepoPullPatchNSID = "sh.tangled.repo.pull.patch" 12 + RepoPullNSID = "sh.tangled.repo.pull" 13 13 ) 14 14 15 15 func init() { 16 - util.RegisterType("sh.tangled.repo.pull.patch", &RepoPullPatch{}) 16 + util.RegisterType("sh.tangled.repo.pull", &RepoPull{}) 17 17 } // 18 - // RECORDTYPE: RepoPullPatch 19 - type RepoPullPatch struct { 20 - LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.patch" cborgen:"$type,const=sh.tangled.repo.pull.patch"` 18 + // RECORDTYPE: RepoPull 19 + type RepoPull struct { 20 + LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"` 21 21 Body *string `json:"body,omitempty" cborgen:"body,omitempty"` 22 22 CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"` 23 23 Patch string `json:"patch" cborgen:"patch"` 24 24 PullId int64 `json:"pullId" cborgen:"pullId"` 25 25 SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"` 26 + TargetBranch string `json:"targetBranch" cborgen:"targetBranch"` 26 27 TargetRepo string `json:"targetRepo" cborgen:"targetRepo"` 27 28 Title string `json:"title" cborgen:"title"` 28 29 }
-24
api/tangled/pullstate.go
··· 1 - // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 - 3 - package tangled 4 - 5 - // schema: sh.tangled.repo.pull.state 6 - 7 - import ( 8 - //"github.com/bluesky-social/indigo/lex/util" 9 - ) 10 - 11 - const ( 12 - RepoPullStateNSID = "sh.tangled.repo.pull.state" 13 - ) 14 - 15 - func init() { 16 - //util.RegisterType("sh.tangled.repo.pull.state", &RepoPullState{}) 17 - } // 18 - // RECORDTYPE: RepoPullState 19 - type RepoPullState struct { 20 - LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.state" cborgen:"$type,const=sh.tangled.repo.pull.state"` 21 - Pull string `json:"pull" cborgen:"pull"` 22 - // state: state of the pull request 23 - State *string `json:"state,omitempty" cborgen:"state,omitempty"` 24 - }
+24
api/tangled/pullstatus.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.repo.pull.status 6 + 7 + import ( 8 + "github.com/bluesky-social/indigo/lex/util" 9 + ) 10 + 11 + const ( 12 + RepoPullStatusNSID = "sh.tangled.repo.pull.status" 13 + ) 14 + 15 + func init() { 16 + util.RegisterType("sh.tangled.repo.pull.status", &RepoPullStatus{}) 17 + } // 18 + // RECORDTYPE: RepoPullStatus 19 + type RepoPullStatus struct { 20 + LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.status" cborgen:"$type,const=sh.tangled.repo.pull.status"` 21 + Pull string `json:"pull" cborgen:"pull"` 22 + // status: status of the pull request 23 + Status *string `json:"status,omitempty" cborgen:"status,omitempty"` 24 + }
+2 -2
api/tangled/stateclosed.go
··· 2 2 3 3 package tangled 4 4 5 - // schema: sh.tangled.repo.pull.state.closed 5 + // schema: sh.tangled.repo.issue.state.closed 6 6 7 7 const () 8 8 9 - const RepoPullStateClosed = "sh.tangled.repo.pull.state.closed" 9 + const RepoIssueStateClosed = "sh.tangled.repo.issue.state.closed"
-9
api/tangled/statemerged.go
··· 1 - // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 - 3 - package tangled 4 - 5 - // schema: sh.tangled.repo.pull.state.merged 6 - 7 - const () 8 - 9 - const RepoPullStateMerged = "sh.tangled.repo.pull.state.merged"
+2 -2
api/tangled/stateopen.go
··· 2 2 3 3 package tangled 4 4 5 - // schema: sh.tangled.repo.pull.state.open 5 + // schema: sh.tangled.repo.issue.state.open 6 6 7 7 const () 8 8 9 - const RepoPullStateOpen = "sh.tangled.repo.pull.state.open" 9 + const RepoIssueStateOpen = "sh.tangled.repo.issue.state.open"
+9
api/tangled/statusclosed.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.repo.pull.status.closed 6 + 7 + const () 8 + 9 + const RepoPullStatusClosed = "sh.tangled.repo.pull.status.closed"
+9
api/tangled/statusmerged.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.repo.pull.status.merged 6 + 7 + const () 8 + 9 + const RepoPullStatusMerged = "sh.tangled.repo.pull.status.merged"
+9
api/tangled/statusopen.go
··· 1 + // Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 + 3 + package tangled 4 + 5 + // schema: sh.tangled.repo.pull.status.open 6 + 7 + const () 8 + 9 + const RepoPullStatusOpen = "sh.tangled.repo.pull.status.open"
+1 -1
lexicons/pulls/closed.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "sh.tangled.repo.pull.state.closed", 3 + "id": "sh.tangled.repo.pull.status.closed", 4 4 "needsCbor": true, 5 5 "needsType": true, 6 6 "defs": {
+1 -1
lexicons/pulls/merged.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "sh.tangled.repo.pull.state.merged", 3 + "id": "sh.tangled.repo.pull.status.merged", 4 4 "needsCbor": true, 5 5 "needsType": true, 6 6 "defs": {
+1 -1
lexicons/pulls/open.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "sh.tangled.repo.pull.state.open", 3 + "id": "sh.tangled.repo.pull.status.open", 4 4 "needsCbor": true, 5 5 "needsType": true, 6 6 "defs": {
+5 -2
lexicons/pulls/patch.json lexicons/pulls/pull.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "sh.tangled.repo.pull.patch", 3 + "id": "sh.tangled.repo.pull", 4 4 "needsCbor": true, 5 5 "needsType": true, 6 6 "defs": { ··· 9 9 "key": "tid", 10 10 "record": { 11 11 "type": "object", 12 - "required": ["targetRepo", "pullId", "title", "patch"], 12 + "required": ["targetRepo", "targetBranch", "pullId", "title", "patch"], 13 13 "properties": { 14 14 "targetRepo": { 15 15 "type": "string", 16 16 "format": "at-uri" 17 + }, 18 + "targetBranch": { 19 + "type": "string" 17 20 }, 18 21 "sourceRepo": { 19 22 "type": "string",
+7 -7
lexicons/pulls/state.json
··· 1 1 { 2 2 "lexicon": 1, 3 - "id": "sh.tangled.repo.pull.state", 3 + "id": "sh.tangled.repo.pull.status", 4 4 "needsCbor": true, 5 5 "needsType": true, 6 6 "defs": { ··· 15 15 "type": "string", 16 16 "format": "at-uri" 17 17 }, 18 - "state": { 18 + "status": { 19 19 "type": "string", 20 - "description": "state of the pull request", 20 + "description": "status of the pull request", 21 21 "knownValues": [ 22 - "sh.tangled.repo.pull.state.open", 23 - "sh.tangled.repo.pull.state.closed", 24 - "sh.tangled.repo.pull.state.merged" 22 + "sh.tangled.repo.pull.status.open", 23 + "sh.tangled.repo.pull.status.closed", 24 + "sh.tangled.repo.pull.status.merged" 25 25 ], 26 - "default": "sh.tangled.repo.pull.state.open" 26 + "default": "sh.tangled.repo.pull.status.open" 27 27 } 28 28 } 29 29 }