aboutsummaryrefslogtreecommitdiff
path: root/modules/git/repo_language_stats_gogit.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo_language_stats_gogit.go')
-rw-r--r--modules/git/repo_language_stats_gogit.go31
1 files changed, 2 insertions, 29 deletions
diff --git a/modules/git/repo_language_stats_gogit.go b/modules/git/repo_language_stats_gogit.go
index 3c9f026b7..34b0dc45d 100644
--- a/modules/git/repo_language_stats_gogit.go
+++ b/modules/git/repo_language_stats_gogit.go
@@ -8,12 +8,10 @@ package git
import (
"bytes"
- "context"
"io"
"strings"
"code.gitea.io/gitea/modules/analyze"
- "code.gitea.io/gitea/modules/log"
"github.com/go-enry/go-enry/v2"
"github.com/go-git/go-git/v5"
@@ -43,33 +41,8 @@ func (repo *Repository) GetLanguageStats(commitID string) (map[string]int64, err
return nil, err
}
- var checker *CheckAttributeReader
-
- if CheckGitVersionAtLeast("1.7.8") == nil {
- indexFilename, workTree, deleteTemporaryFile, err := repo.ReadTreeToTemporaryIndex(commitID)
- if err == nil {
- defer deleteTemporaryFile()
- checker = &CheckAttributeReader{
- Attributes: []string{"linguist-vendored", "linguist-generated", "linguist-language", "gitlab-language"},
- Repo: repo,
- IndexFile: indexFilename,
- WorkTree: workTree,
- }
- ctx, cancel := context.WithCancel(DefaultContext)
- if err := checker.Init(ctx); err != nil {
- log.Error("Unable to open checker for %s. Error: %v", commitID, err)
- } else {
- go func() {
- err = checker.Run()
- if err != nil {
- log.Error("Unable to open checker for %s. Error: %v", commitID, err)
- cancel()
- }
- }()
- }
- defer cancel()
- }
- }
+ checker, deferable := repo.CheckAttributeReader(commitID)
+ defer deferable()
sizes := make(map[string]int64)
err = tree.Files().ForEach(func(f *object.File) error {