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

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
···
nd.Stat.FilesChanged = len(diffs)
nd.Commit.This = c.Hash.String()
+
nd.Commit.PGPSignature = c.PGPSignature
+
nd.Commit.Committer = c.Committer
+
nd.Commit.Tree = c.TreeHash.String()
if parent.Hash.IsZero() {
nd.Commit.Parent = ""
···
}
nd.Commit.Author = c.Author
nd.Commit.Message = c.Message
+
+
if v, ok := c.ExtraHeaders["change-id"]; ok {
+
nd.Commit.ChangedId = string(v)
+
}
return &nd, nil
}
+8 -4
types/diff.go
···
// A nicer git diff representation.
type NiceDiff struct {
Commit struct {
-
Message string `json:"message"`
-
Author object.Signature `json:"author"`
-
This string `json:"this"`
-
Parent string `json:"parent"`
+
Message string `json:"message"`
+
Author object.Signature `json:"author"`
+
This string `json:"this"`
+
Parent string `json:"parent"`
+
PGPSignature string `json:"pgp_signature"`
+
Committer object.Signature `json:"committer"`
+
Tree string `json:"tree"`
+
ChangedId string `json:"change_id"`
} `json:"commit"`
Stat struct {
FilesChanged int `json:"files_changed"`