From c387d693d6e05d86d5b1176254e389db75ba3c6a Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Mon, 15 Jun 2026 01:21:13 +0900 Subject: [PATCH] lexicons/git: add `changedFiles` in `git.refUpdate` Signed-off-by: Seongmin Lee --- api/tangled/cbor_gen.go | 162 +++++++++++++++++++++++++++++++++++- api/tangled/gitrefUpdate.go | 4 + lexicons/git/refUpdate.json | 22 ++++- 3 files changed, 186 insertions(+), 2 deletions(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 102df34f..b1351655 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -1611,12 +1611,20 @@ func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { } cw := cbg.NewCborWriter(w) - fieldCount := 8 + fieldCount := 10 + + if t.ChangedFiles == nil { + fieldCount-- + } if t.OwnerDid == nil { fieldCount-- } + if t.PushOptions == nil { + fieldCount-- + } + if _, err := cw.Write(cbg.CborEncodeMajorType(cbg.MajMap, uint64(fieldCount))); err != nil { return err } @@ -1780,6 +1788,78 @@ func (t *GitRefUpdate) MarshalCBOR(w io.Writer) error { } } + // t.PushOptions ([]string) (slice) + if t.PushOptions != nil { + + if len("pushOptions") > 1000000 { + return xerrors.Errorf("Value in field \"pushOptions\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("pushOptions"))); err != nil { + return err + } + if _, err := cw.WriteString(string("pushOptions")); err != nil { + return err + } + + if len(t.PushOptions) > 8192 { + return xerrors.Errorf("Slice value in field t.PushOptions was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.PushOptions))); err != nil { + return err + } + for _, v := range t.PushOptions { + if len(v) > 1000000 { + return xerrors.Errorf("Value in field v was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { + return err + } + if _, err := cw.WriteString(string(v)); err != nil { + return err + } + + } + } + + // t.ChangedFiles ([]string) (slice) + if t.ChangedFiles != nil { + + if len("changedFiles") > 1000000 { + return xerrors.Errorf("Value in field \"changedFiles\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("changedFiles"))); err != nil { + return err + } + if _, err := cw.WriteString(string("changedFiles")); err != nil { + return err + } + + if len(t.ChangedFiles) > 8192 { + return xerrors.Errorf("Slice value in field t.ChangedFiles was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajArray, uint64(len(t.ChangedFiles))); err != nil { + return err + } + for _, v := range t.ChangedFiles { + if len(v) > 1000000 { + return xerrors.Errorf("Value in field v was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len(v))); err != nil { + return err + } + if _, err := cw.WriteString(string(v)); err != nil { + return err + } + + } + } + // t.CommitterDid (string) (string) if len("committerDid") > 1000000 { return xerrors.Errorf("Value in field \"committerDid\" was too long") @@ -1942,6 +2022,86 @@ func (t *GitRefUpdate) UnmarshalCBOR(r io.Reader) (err error) { t.OwnerDid = (*string)(&sval) } } + // t.PushOptions ([]string) (slice) + case "pushOptions": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.PushOptions: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.PushOptions = make([]string, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.PushOptions[i] = string(sval) + } + + } + } + // t.ChangedFiles ([]string) (slice) + case "changedFiles": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + + if extra > 8192 { + return fmt.Errorf("t.ChangedFiles: array too large (%d)", extra) + } + + if maj != cbg.MajArray { + return fmt.Errorf("expected cbor array") + } + + if extra > 0 { + t.ChangedFiles = make([]string, extra) + } + + for i := 0; i < int(extra); i++ { + { + var maj byte + var extra uint64 + var err error + _ = maj + _ = extra + _ = err + + { + sval, err := cbg.ReadStringWithMax(cr, 1000000) + if err != nil { + return err + } + + t.ChangedFiles[i] = string(sval) + } + + } + } // t.CommitterDid (string) (string) case "committerDid": diff --git a/api/tangled/gitrefUpdate.go b/api/tangled/gitrefUpdate.go index 670d036c..a3f6c759 100644 --- a/api/tangled/gitrefUpdate.go +++ b/api/tangled/gitrefUpdate.go @@ -18,6 +18,8 @@ func init() { // RECORDTYPE: GitRefUpdate type GitRefUpdate struct { LexiconTypeID string `json:"$type,const=sh.tangled.git.refUpdate" cborgen:"$type,const=sh.tangled.git.refUpdate"` + // changedFiles: files changed between commits + ChangedFiles []string `json:"changedFiles,omitempty" cborgen:"changedFiles,omitempty"` // committerDid: did of the user that pushed this ref CommitterDid string `json:"committerDid" cborgen:"committerDid"` Meta *GitRefUpdate_Meta `json:"meta" cborgen:"meta"` @@ -27,6 +29,8 @@ type GitRefUpdate struct { OldSha string `json:"oldSha" cborgen:"oldSha"` // ownerDid: did of the owner of the repo OwnerDid *string `json:"ownerDid,omitempty" cborgen:"ownerDid,omitempty"` + // pushOptions: push options passed on git-push + PushOptions []string `json:"pushOptions,omitempty" cborgen:"pushOptions,omitempty"` // ref: Ref being updated Ref string `json:"ref" cborgen:"ref"` // repo: DID of the repo itself diff --git a/lexicons/git/refUpdate.json b/lexicons/git/refUpdate.json index 6b8c04d7..c37f611a 100644 --- a/lexicons/git/refUpdate.json +++ b/lexicons/git/refUpdate.json @@ -4,7 +4,7 @@ "defs": { "main": { "type": "record", - "description": "An update to a git repository, emitted by knots.", + "description": "An event record representing git-push operation to git repository, emitted by knots.", "key": "tid", "record": { "type": "object", @@ -50,6 +50,26 @@ "minLength": 40, "maxLength": 40 }, + "changedFiles": { + "type": "array", + "description": "files changed between commits", + "items": { "type": "string" } + }, + "pushOptions": { + "type": "array", + "description": "push options passed on git-push", + "maxLength": 50, + "items": { + "type": "string", + "maxLength": 1024, + "knownValues": [ + "ci-skip", + "ci-verbose", + "skip-ci", + "verbose-ci" + ] + } + }, "meta": { "type": "ref", "ref": "#meta" -- 2.51.2