fix: include file stat bug (#1107)

This commit is contained in:
Abhinav Singh 2024-03-07 13:53:38 +00:00 committed by Harness
parent 5fd2dc067c
commit fd9f95c82b

View File

@ -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,