forked from tangled.org/core
Monorepo for Tangled

knotserver: git: add more fields to NiceDiff.Commit

These should now let us reconstruct the commit object (or at least the
git cat-file equivalent) appview-side.

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

anirudh.fi 898e814a b08135c8

verified
Changed files
+15 -4
knotserver
git
types
+7
knotserver/git/diff.go
··· 79 80 nd.Stat.FilesChanged = len(diffs) 81 nd.Commit.This = c.Hash.String() 82 83 if parent.Hash.IsZero() { 84 nd.Commit.Parent = "" ··· 87 } 88 nd.Commit.Author = c.Author 89 nd.Commit.Message = c.Message 90 91 return &nd, nil 92 }
··· 79 80 nd.Stat.FilesChanged = len(diffs) 81 nd.Commit.This = c.Hash.String() 82 + nd.Commit.PGPSignature = c.PGPSignature 83 + nd.Commit.Committer = c.Committer 84 + nd.Commit.Tree = c.TreeHash.String() 85 86 if parent.Hash.IsZero() { 87 nd.Commit.Parent = "" ··· 90 } 91 nd.Commit.Author = c.Author 92 nd.Commit.Message = c.Message 93 + 94 + if v, ok := c.ExtraHeaders["change-id"]; ok { 95 + nd.Commit.ChangedId = string(v) 96 + } 97 98 return &nd, nil 99 }
+8 -4
types/diff.go
··· 40 // A nicer git diff representation. 41 type NiceDiff struct { 42 Commit struct { 43 - Message string `json:"message"` 44 - Author object.Signature `json:"author"` 45 - This string `json:"this"` 46 - Parent string `json:"parent"` 47 } `json:"commit"` 48 Stat struct { 49 FilesChanged int `json:"files_changed"`
··· 40 // A nicer git diff representation. 41 type NiceDiff struct { 42 Commit struct { 43 + Message string `json:"message"` 44 + Author object.Signature `json:"author"` 45 + This string `json:"this"` 46 + Parent string `json:"parent"` 47 + PGPSignature string `json:"pgp_signature"` 48 + Committer object.Signature `json:"committer"` 49 + Tree string `json:"tree"` 50 + ChangedId string `json:"change_id"` 51 } `json:"commit"` 52 Stat struct { 53 FilesChanged int `json:"files_changed"`