forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

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.

+64 -30
api/tangled/cbor_gen.go
···
return nil
-
func (t *RepoPullPatch) MarshalCBOR(w io.Writer) error {
+
func (t *RepoPull) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
cw := cbg.NewCborWriter(w)
-
fieldCount := 8
+
fieldCount := 9
if t.Body == nil {
fieldCount--
···
return err
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.patch"))); err != nil {
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull"))); err != nil {
return err
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull.patch")); err != nil {
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull")); err != nil {
return err
···
if _, err := cw.WriteString(string(t.TargetRepo)); err != nil {
return err
+
+
// t.TargetBranch (string) (string)
+
if len("targetBranch") > 1000000 {
+
return xerrors.Errorf("Value in field \"targetBranch\" was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("targetBranch"))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string("targetBranch")); err != nil {
+
return err
+
}
+
+
if len(t.TargetBranch) > 1000000 {
+
return xerrors.Errorf("Value in field t.TargetBranch was too long")
+
}
+
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(t.TargetBranch))); err != nil {
+
return err
+
}
+
if _, err := cw.WriteString(string(t.TargetBranch)); err != nil {
+
return err
+
}
return nil
-
func (t *RepoPullPatch) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = RepoPullPatch{}
+
func (t *RepoPull) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = RepoPull{}
cr := cbg.NewCborReader(r)
···
if extra > cbg.MaxLength {
-
return fmt.Errorf("RepoPullPatch: map struct too large (%d)", extra)
+
return fmt.Errorf("RepoPull: map struct too large (%d)", extra)
n := extra
-
nameBuf := make([]byte, 10)
+
nameBuf := make([]byte, 12)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
t.TargetRepo = string(sval)
+
// t.TargetBranch (string) (string)
+
case "targetBranch":
+
+
{
+
sval, err := cbg.ReadStringWithMax(cr, 1000000)
+
if err != nil {
+
return err
+
}
+
+
t.TargetBranch = string(sval)
+
}
default:
// Field doesn't exist on this type, so ignore it
···
return nil
-
func (t *RepoPullState) MarshalCBOR(w io.Writer) error {
+
func (t *RepoPullStatus) MarshalCBOR(w io.Writer) error {
if t == nil {
_, err := w.Write(cbg.CborNull)
return err
···
cw := cbg.NewCborWriter(w)
fieldCount := 3
-
if t.State == nil {
+
if t.Status == nil {
fieldCount--
···
return err
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.state"))); err != nil {
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("sh.tangled.repo.pull.status"))); err != nil {
return err
-
if _, err := cw.WriteString(string("sh.tangled.repo.pull.state")); err != nil {
+
if _, err := cw.WriteString(string("sh.tangled.repo.pull.status")); err != nil {
return err
-
// t.State (string) (string)
-
if t.State != nil {
+
// t.Status (string) (string)
+
if t.Status != nil {
-
if len("state") > 1000000 {
-
return xerrors.Errorf("Value in field \"state\" was too long")
+
if len("status") > 1000000 {
+
return xerrors.Errorf("Value in field \"status\" was too long")
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("state"))); err != nil {
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("status"))); err != nil {
return err
-
if _, err := cw.WriteString(string("state")); err != nil {
+
if _, err := cw.WriteString(string("status")); err != nil {
return err
-
if t.State == nil {
+
if t.Status == nil {
if _, err := cw.Write(cbg.CborNull); err != nil {
return err
} else {
-
if len(*t.State) > 1000000 {
-
return xerrors.Errorf("Value in field t.State was too long")
+
if len(*t.Status) > 1000000 {
+
return xerrors.Errorf("Value in field t.Status was too long")
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.State))); err != nil {
+
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(*t.Status))); err != nil {
return err
-
if _, err := cw.WriteString(string(*t.State)); err != nil {
+
if _, err := cw.WriteString(string(*t.Status)); err != nil {
return err
···
return nil
-
func (t *RepoPullState) UnmarshalCBOR(r io.Reader) (err error) {
-
*t = RepoPullState{}
+
func (t *RepoPullStatus) UnmarshalCBOR(r io.Reader) (err error) {
+
*t = RepoPullStatus{}
cr := cbg.NewCborReader(r)
···
if extra > cbg.MaxLength {
-
return fmt.Errorf("RepoPullState: map struct too large (%d)", extra)
+
return fmt.Errorf("RepoPullStatus: map struct too large (%d)", extra)
n := extra
-
nameBuf := make([]byte, 5)
+
nameBuf := make([]byte, 6)
for i := uint64(0); i < n; i++ {
nameLen, ok, err := cbg.ReadFullStringIntoBuf(cr, nameBuf, 1000000)
if err != nil {
···
t.LexiconTypeID = string(sval)
-
// t.State (string) (string)
-
case "state":
+
// t.Status (string) (string)
+
case "status":
b, err := cr.ReadByte()
···
return err
-
t.State = (*string)(&sval)
+
t.Status = (*string)(&sval)
+2 -2
api/tangled/pullcomment.go
···
// schema: sh.tangled.repo.pull.comment
import (
-
//"github.com/bluesky-social/indigo/lex/util"
+
"github.com/bluesky-social/indigo/lex/util"
)
const (
···
)
func init() {
-
//util.RegisterType("sh.tangled.repo.pull.comment", &RepoPullComment{})
+
util.RegisterType("sh.tangled.repo.pull.comment", &RepoPullComment{})
} //
// RECORDTYPE: RepoPullComment
type RepoPullComment struct {
+7 -6
api/tangled/pullpatch.go api/tangled/repopull.go
···
package tangled
-
// schema: sh.tangled.repo.pull.patch
+
// schema: sh.tangled.repo.pull
import (
"github.com/bluesky-social/indigo/lex/util"
)
const (
-
RepoPullPatchNSID = "sh.tangled.repo.pull.patch"
+
RepoPullNSID = "sh.tangled.repo.pull"
)
func init() {
-
util.RegisterType("sh.tangled.repo.pull.patch", &RepoPullPatch{})
+
util.RegisterType("sh.tangled.repo.pull", &RepoPull{})
} //
-
// RECORDTYPE: RepoPullPatch
-
type RepoPullPatch struct {
-
LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.patch" cborgen:"$type,const=sh.tangled.repo.pull.patch"`
+
// RECORDTYPE: RepoPull
+
type RepoPull struct {
+
LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull" cborgen:"$type,const=sh.tangled.repo.pull"`
Body *string `json:"body,omitempty" cborgen:"body,omitempty"`
CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"`
Patch string `json:"patch" cborgen:"patch"`
PullId int64 `json:"pullId" cborgen:"pullId"`
SourceRepo *string `json:"sourceRepo,omitempty" cborgen:"sourceRepo,omitempty"`
+
TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
TargetRepo string `json:"targetRepo" cborgen:"targetRepo"`
Title string `json:"title" cborgen:"title"`
}
-24
api/tangled/pullstate.go
···
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
-
-
package tangled
-
-
// schema: sh.tangled.repo.pull.state
-
-
import (
-
//"github.com/bluesky-social/indigo/lex/util"
-
)
-
-
const (
-
RepoPullStateNSID = "sh.tangled.repo.pull.state"
-
)
-
-
func init() {
-
//util.RegisterType("sh.tangled.repo.pull.state", &RepoPullState{})
-
} //
-
// RECORDTYPE: RepoPullState
-
type RepoPullState struct {
-
LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.state" cborgen:"$type,const=sh.tangled.repo.pull.state"`
-
Pull string `json:"pull" cborgen:"pull"`
-
// state: state of the pull request
-
State *string `json:"state,omitempty" cborgen:"state,omitempty"`
-
}
+24
api/tangled/pullstatus.go
···
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
+
+
package tangled
+
+
// schema: sh.tangled.repo.pull.status
+
+
import (
+
"github.com/bluesky-social/indigo/lex/util"
+
)
+
+
const (
+
RepoPullStatusNSID = "sh.tangled.repo.pull.status"
+
)
+
+
func init() {
+
util.RegisterType("sh.tangled.repo.pull.status", &RepoPullStatus{})
+
} //
+
// RECORDTYPE: RepoPullStatus
+
type RepoPullStatus struct {
+
LexiconTypeID string `json:"$type,const=sh.tangled.repo.pull.status" cborgen:"$type,const=sh.tangled.repo.pull.status"`
+
Pull string `json:"pull" cborgen:"pull"`
+
// status: status of the pull request
+
Status *string `json:"status,omitempty" cborgen:"status,omitempty"`
+
}
+2 -2
api/tangled/stateclosed.go
···
package tangled
-
// schema: sh.tangled.repo.pull.state.closed
+
// schema: sh.tangled.repo.issue.state.closed
const ()
-
const RepoPullStateClosed = "sh.tangled.repo.pull.state.closed"
+
const RepoIssueStateClosed = "sh.tangled.repo.issue.state.closed"
-9
api/tangled/statemerged.go
···
-
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
-
-
package tangled
-
-
// schema: sh.tangled.repo.pull.state.merged
-
-
const ()
-
-
const RepoPullStateMerged = "sh.tangled.repo.pull.state.merged"
+2 -2
api/tangled/stateopen.go
···
package tangled
-
// schema: sh.tangled.repo.pull.state.open
+
// schema: sh.tangled.repo.issue.state.open
const ()
-
const RepoPullStateOpen = "sh.tangled.repo.pull.state.open"
+
const RepoIssueStateOpen = "sh.tangled.repo.issue.state.open"
+9
api/tangled/statusclosed.go
···
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
+
+
package tangled
+
+
// schema: sh.tangled.repo.pull.status.closed
+
+
const ()
+
+
const RepoPullStatusClosed = "sh.tangled.repo.pull.status.closed"
+9
api/tangled/statusmerged.go
···
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
+
+
package tangled
+
+
// schema: sh.tangled.repo.pull.status.merged
+
+
const ()
+
+
const RepoPullStatusMerged = "sh.tangled.repo.pull.status.merged"
+9
api/tangled/statusopen.go
···
+
// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
+
+
package tangled
+
+
// schema: sh.tangled.repo.pull.status.open
+
+
const ()
+
+
const RepoPullStatusOpen = "sh.tangled.repo.pull.status.open"
+1 -1
lexicons/pulls/closed.json
···
{
"lexicon": 1,
-
"id": "sh.tangled.repo.pull.state.closed",
+
"id": "sh.tangled.repo.pull.status.closed",
"needsCbor": true,
"needsType": true,
"defs": {
+1 -1
lexicons/pulls/merged.json
···
{
"lexicon": 1,
-
"id": "sh.tangled.repo.pull.state.merged",
+
"id": "sh.tangled.repo.pull.status.merged",
"needsCbor": true,
"needsType": true,
"defs": {
+1 -1
lexicons/pulls/open.json
···
{
"lexicon": 1,
-
"id": "sh.tangled.repo.pull.state.open",
+
"id": "sh.tangled.repo.pull.status.open",
"needsCbor": true,
"needsType": true,
"defs": {
+5 -2
lexicons/pulls/patch.json lexicons/pulls/pull.json
···
{
"lexicon": 1,
-
"id": "sh.tangled.repo.pull.patch",
+
"id": "sh.tangled.repo.pull",
"needsCbor": true,
"needsType": true,
"defs": {
···
"key": "tid",
"record": {
"type": "object",
-
"required": ["targetRepo", "pullId", "title", "patch"],
+
"required": ["targetRepo", "targetBranch", "pullId", "title", "patch"],
"properties": {
"targetRepo": {
"type": "string",
"format": "at-uri"
+
},
+
"targetBranch": {
+
"type": "string"
},
"sourceRepo": {
"type": "string",
+7 -7
lexicons/pulls/state.json
···
{
"lexicon": 1,
-
"id": "sh.tangled.repo.pull.state",
+
"id": "sh.tangled.repo.pull.status",
"needsCbor": true,
"needsType": true,
"defs": {
···
"type": "string",
"format": "at-uri"
},
-
"state": {
+
"status": {
"type": "string",
-
"description": "state of the pull request",
+
"description": "status of the pull request",
"knownValues": [
-
"sh.tangled.repo.pull.state.open",
-
"sh.tangled.repo.pull.state.closed",
-
"sh.tangled.repo.pull.state.merged"
+
"sh.tangled.repo.pull.status.open",
+
"sh.tangled.repo.pull.status.closed",
+
"sh.tangled.repo.pull.status.merged"
],
-
"default": "sh.tangled.repo.pull.state.open"
+
"default": "sh.tangled.repo.pull.status.open"
}
}
}