From fd9f95c82bb85a0311d39873f4e2ffd3d63d2948 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Thu, 7 Mar 2024 13:53:38 +0000 Subject: [PATCH] fix: include file stat bug (#1107) --- git/adapter/commit.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/git/adapter/commit.go b/git/adapter/commit.go index 3e333a60a..7bb41a491 100644 --- a/git/adapter/commit.go +++ b/git/adapter/commit.go @@ -175,10 +175,11 @@ func (a Adapter) ListCommits( commits[i] = *commit if includeFileStats { - err = includeFileStatsInCommits(ctx, giteaRepo, commits) + fileStat, err := getFileStats(ctx, giteaRepo, commit.SHA) if err != nil { - return nil, nil, err + return nil, nil, fmt.Errorf("encountered error getting file stat: %w", err) } + commit.FileStats = fileStat } } @@ -194,21 +195,6 @@ func (a Adapter) ListCommits( return commits, nil, nil } -func includeFileStatsInCommits( - ctx context.Context, - giteaRepo *gitea.Repository, - commits []types.Commit, -) error { - for i, commit := range commits { - fileStats, err := getFileStats(ctx, giteaRepo, commit.SHA) - if err != nil { - return fmt.Errorf("failed to get file stat: %w", err) - } - commits[i].FileStats = fileStats - } - return nil -} - func getFileStats( ctx context.Context, giteaRepo *gitea.Repository,