From ea1b37296145f86a892f2fd880ece1288ad2da01 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Thu, 29 May 2025 15:38:09 +0300 Subject: [PATCH] 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 --- knotserver/git/diff.go | 7 +++++++ types/diff.go | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/knotserver/git/diff.go b/knotserver/git/diff.go index cc065b1c..81b6c736 100644 --- a/knotserver/git/diff.go +++ b/knotserver/git/diff.go @@ -79,6 +79,9 @@ func (g *GitRepo) Diff() (*types.NiceDiff, error) { 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 = "" @@ -88,6 +91,10 @@ func (g *GitRepo) Diff() (*types.NiceDiff, error) { 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 } diff --git a/types/diff.go b/types/diff.go index a9a809b4..5978dc6d 100644 --- a/types/diff.go +++ b/types/diff.go @@ -40,10 +40,14 @@ func (d *Diff) Stats() DiffStat { // 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"` -- 2.51.2