aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_activity.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo_activity.go')
-rw-r--r--models/repo_activity.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/models/repo_activity.go b/models/repo_activity.go
index 5bdea80b97..7475be2b11 100644
--- a/models/repo_activity.go
+++ b/models/repo_activity.go
@@ -5,6 +5,7 @@
package models
import (
+ "context"
"fmt"
"sort"
"time"
@@ -43,7 +44,7 @@ type ActivityStats struct {
}
// GetActivityStats return stats for repository at given time range
-func GetActivityStats(repo *repo_model.Repository, timeFrom time.Time, releases, issues, prs, code bool) (*ActivityStats, error) {
+func GetActivityStats(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, releases, issues, prs, code bool) (*ActivityStats, error) {
stats := &ActivityStats{Code: &git.CodeActivityStats{}}
if releases {
if err := stats.FillReleases(repo.ID, timeFrom); err != nil {
@@ -64,11 +65,11 @@ func GetActivityStats(repo *repo_model.Repository, timeFrom time.Time, releases,
return nil, fmt.Errorf("FillUnresolvedIssues: %v", err)
}
if code {
- gitRepo, err := git.OpenRepository(repo.RepoPath())
+ gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath())
if err != nil {
return nil, fmt.Errorf("OpenRepository: %v", err)
}
- defer gitRepo.Close()
+ defer closer.Close()
code, err := gitRepo.GetCodeActivityStats(timeFrom, repo.DefaultBranch)
if err != nil {
@@ -80,12 +81,12 @@ func GetActivityStats(repo *repo_model.Repository, timeFrom time.Time, releases,
}
// GetActivityStatsTopAuthors returns top author stats for git commits for all branches
-func GetActivityStatsTopAuthors(repo *repo_model.Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error) {
- gitRepo, err := git.OpenRepository(repo.RepoPath())
+func GetActivityStatsTopAuthors(ctx context.Context, repo *repo_model.Repository, timeFrom time.Time, count int) ([]*ActivityAuthorData, error) {
+ gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.RepoPath())
if err != nil {
return nil, fmt.Errorf("OpenRepository: %v", err)
}
- defer gitRepo.Close()
+ defer closer.Close()
code, err := gitRepo.GetCodeActivityStats(timeFrom, "")
if err != nil {