mirror of
https://github.com/harness/drone.git
synced 2025-05-04 13:59:04 +08:00
fix: include file stat bug (#1107)
This commit is contained in:
parent
5fd2dc067c
commit
fd9f95c82b
@ -175,10 +175,11 @@ func (a Adapter) ListCommits(
|
|||||||
commits[i] = *commit
|
commits[i] = *commit
|
||||||
|
|
||||||
if includeFileStats {
|
if includeFileStats {
|
||||||
err = includeFileStatsInCommits(ctx, giteaRepo, commits)
|
fileStat, err := getFileStats(ctx, giteaRepo, commit.SHA)
|
||||||
if err != nil {
|
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
|
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(
|
func getFileStats(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
giteaRepo *gitea.Repository,
|
giteaRepo *gitea.Repository,
|
||||||
|
Loading…
Reference in New Issue
Block a user