diff options
Diffstat (limited to 'modules/git/repo_stats.go')
-rw-r--r-- | modules/git/repo_stats.go | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/modules/git/repo_stats.go b/modules/git/repo_stats.go index 6f5973ebe5..598ec37a2c 100644 --- a/modules/git/repo_stats.go +++ b/modules/git/repo_stats.go @@ -67,12 +67,14 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) } stderr := new(strings.Builder) - err = NewCommand(repo.Ctx, args...).RunInDirTimeoutEnvFullPipelineFunc( - nil, -1, repo.Path, - stdoutWriter, stderr, nil, - func(ctx context.Context, cancel context.CancelFunc) error { + err = NewCommand(repo.Ctx, args...).RunWithContext(&RunContext{ + Env: []string{}, + Timeout: -1, + Dir: repo.Path, + Stdout: stdoutWriter, + Stderr: stderr, + PipelineFunc: func(ctx context.Context, cancel context.CancelFunc) error { _ = stdoutWriter.Close() - scanner := bufio.NewScanner(stdoutReader) scanner.Split(bufio.ScanLines) stats.CommitCount = 0 @@ -103,11 +105,7 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) case 4: // E-mail email := strings.ToLower(l) if _, ok := authors[email]; !ok { - authors[email] = &CodeActivityAuthor{ - Name: author, - Email: email, - Commits: 0, - } + authors[email] = &CodeActivityAuthor{Name: author, Email: email, Commits: 0} } authors[email].Commits++ default: // Changed file @@ -128,7 +126,6 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) } } } - a := make([]*CodeActivityAuthor, 0, len(authors)) for _, v := range authors { a = append(a, v) @@ -137,14 +134,13 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) sort.Slice(a, func(i, j int) bool { return a[i].Commits > a[j].Commits }) - stats.AuthorCount = int64(len(authors)) stats.ChangedFiles = int64(len(files)) stats.Authors = a - _ = stdoutReader.Close() return nil - }) + }, + }) if err != nil { return nil, fmt.Errorf("Failed to get GetCodeActivityStats for repository.\nError: %w\nStderr: %s", err, stderr) } |