From 9271b27511a05818b0d5babc2fb0e395b6d2e3a8 Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Tue, 7 Feb 2023 14:44:02 -0800 Subject: [PATCH] add additional params to commit loader --- commits/chancommits.go | 15 ++++++++++++++- commits/commits.go | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/commits/chancommits.go b/commits/chancommits.go index 40841dd..cc8b51c 100644 --- a/commits/chancommits.go +++ b/commits/chancommits.go @@ -78,7 +78,20 @@ func (repo Repo) GetCommitChan() (chan types.Commit, error) { go func() { cIter.ForEach(func(c *object.Commit) error { ts := c.Author.When - commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} + commit := types.Commit{ + Author: c.Author.Name, + Message: c.Message, TimeStamp: ts, + Hash: c.Hash.String(), Repo: repo.Path, + FilesChanged: 0, Added: 0, Deleted: 0, + } + stats, err := c.Stats() + if err != nil { + for _, stat := range stats { + commit.Added += stat.Addition + commit.Deleted += stat.Deletion + commit.FilesChanged++ + } + } cc <- commit return nil }) diff --git a/commits/commits.go b/commits/commits.go index 8487d12..2cf3676 100644 --- a/commits/commits.go +++ b/commits/commits.go @@ -87,7 +87,20 @@ func (repo Repo) GetCommitSet() (CommitSet, error) { } cIter.ForEach(func(c *object.Commit) error { ts := c.Author.When - commit := types.Commit{Author: c.Author.Name, Message: c.Message, TimeStamp: ts} + commit := types.Commit{ + Author: c.Author.Name, + Message: c.Message, TimeStamp: ts, + Hash: c.Hash.String(), Repo: repo.Path, + FilesChanged: 0, Added: 0, Deleted: 0, + } + stats, err := c.Stats() + if err != nil { + for _, stat := range stats { + commit.Added += stat.Addition + commit.Deleted += stat.Deletion + commit.FilesChanged++ + } + } commits = append(commits, commit) return nil })