diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-06-16 23:47:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 23:47:44 +0800 |
commit | 157b4057531b99b2d3b5c086f385c830aa38354f (patch) | |
tree | 5a7f066be290cefe174b7f5ab5f48f478921a226 /modules/git/repo_language_stats_nogogit.go | |
parent | 70ce051f1a7e266dccdd7cfd42f88a2570448770 (diff) | |
download | gitea-157b4057531b99b2d3b5c086f385c830aa38354f.tar.gz gitea-157b4057531b99b2d3b5c086f385c830aa38354f.zip |
Remove legacy git code (ver < 2.0), fine tune markup tests (#19930)
* clean git support for ver < 2.0
* fine tune tests for markup (which requires git module)
* remove unnecessary comments
* try to fix tests
* try test again
* use const for GitVersionRequired instead of var
* try to fix integration test
* Refactor CheckAttributeReader to make a *git.Repository version
* update document for commit signing with Gitea's internal gitconfig
* update document for commit signing with Gitea's internal gitconfig
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'modules/git/repo_language_stats_nogogit.go')
-rw-r--r-- | modules/git/repo_language_stats_nogogit.go | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/modules/git/repo_language_stats_nogogit.go b/modules/git/repo_language_stats_nogogit.go index 41b176f816..d237924f92 100644 --- a/modules/git/repo_language_stats_nogogit.go +++ b/modules/git/repo_language_stats_nogogit.go @@ -9,7 +9,6 @@ package git import ( "bufio" "bytes" - "context" "io" "math" "strings" @@ -63,36 +62,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(repo.Ctx) - 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 func() { - _ = checker.Close() - cancel() - }() - } - } + checker, deferable := repo.CheckAttributeReader(commitID) + defer deferable() contentBuf := bytes.Buffer{} var content []byte |