forked from tangled.org/core
this repo has no description

lexicons: pulls: remove pull id from the pull record and instead generate ids purely appview side

Signed-off-by: nelind <nel.n.lindberg@gmail.com>

nel.pet d987a38c f5338509

verified
Changed files
+1 -57
api
appview
db
pulls
lexicons
pulls
+1 -49
api/tangled/cbor_gen.go
···
cw := cbg.NewCborWriter(w)
-
fieldCount := 9
+
fieldCount := 8
if t.Body == nil {
fieldCount--
···
if _, err := cw.WriteString(string(t.Title)); err != nil {
return err
-
}
-
-
// t.PullId (int64) (int64)
-
if len("pullId") > 1000000 {
-
return xerrors.Errorf("Value in field \"pullId\" was too long")
-
}
-
-
if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pullId"))); err != nil {
-
return err
-
}
-
if _, err := cw.WriteString(string("pullId")); err != nil {
-
return err
-
}
-
-
if t.PullId >= 0 {
-
if err := cw.WriteMajorTypeHeader(cbg.MajUnsignedInt, uint64(t.PullId)); err != nil {
-
return err
-
}
-
} else {
-
if err := cw.WriteMajorTypeHeader(cbg.MajNegativeInt, uint64(-t.PullId-1)); err != nil {
-
return err
-
}
// t.Source (tangled.RepoPull_Source) (struct)
···
t.Title = string(sval)
-
}
-
// t.PullId (int64) (int64)
-
case "pullId":
-
{
-
maj, extra, err := cr.ReadHeader()
-
if err != nil {
-
return err
-
}
-
var extraI int64
-
switch maj {
-
case cbg.MajUnsignedInt:
-
extraI = int64(extra)
-
if extraI < 0 {
-
return fmt.Errorf("int64 positive overflow")
-
}
-
case cbg.MajNegativeInt:
-
extraI = int64(extra)
-
if extraI < 0 {
-
return fmt.Errorf("int64 negative overflow")
-
}
-
extraI = -1 - extraI
-
default:
-
return fmt.Errorf("wrong type for int64 field: %d", maj)
-
}
-
-
t.PullId = int64(extraI)
// t.Source (tangled.RepoPull_Source) (struct)
case "source":
-1
api/tangled/repopull.go
···
Body *string `json:"body,omitempty" cborgen:"body,omitempty"`
CreatedAt string `json:"createdAt" cborgen:"createdAt"`
Patch string `json:"patch" cborgen:"patch"`
-
PullId int64 `json:"pullId" cborgen:"pullId"`
Source *RepoPull_Source `json:"source,omitempty" cborgen:"source,omitempty"`
TargetBranch string `json:"targetBranch" cborgen:"targetBranch"`
TargetRepo string `json:"targetRepo" cborgen:"targetRepo"`
-1
appview/db/pulls.go
···
Title: p.Title,
Body: &p.Body,
CreatedAt: p.Created.Format(time.RFC3339),
-
PullId: int64(p.PullId),
TargetRepo: p.RepoAt.String(),
TargetBranch: p.TargetBranch,
Patch: p.LatestPatch(),
-2
appview/pulls/pulls.go
···
Record: &lexutil.LexiconTypeDecoder{
Val: &tangled.RepoPull{
Title: title,
-
PullId: int64(pullId),
TargetRepo: string(f.RepoAt),
TargetBranch: targetBranch,
Patch: patch,
···
Record: &lexutil.LexiconTypeDecoder{
Val: &tangled.RepoPull{
Title: pull.Title,
-
PullId: int64(pull.PullId),
TargetRepo: string(f.RepoAt),
TargetBranch: pull.TargetBranch,
Patch: patch, // new patch
-4
lexicons/pulls/pull.json
···
"required": [
"targetRepo",
"targetBranch",
-
"pullId",
"title",
"patch",
"createdAt"
···
},
"targetBranch": {
"type": "string"
-
},
-
"pullId": {
-
"type": "integer"
},
"title": {
"type": "string"