summaryrefslogtreecommitdiffstats
path: root/services/gitdiff/gitdiff.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-06-16 23:47:44 +0800
committerGitHub <noreply@github.com>2022-06-16 23:47:44 +0800
commit157b4057531b99b2d3b5c086f385c830aa38354f (patch)
tree5a7f066be290cefe174b7f5ab5f48f478921a226 /services/gitdiff/gitdiff.go
parent70ce051f1a7e266dccdd7cfd42f88a2570448770 (diff)
downloadgitea-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 'services/gitdiff/gitdiff.go')
-rw-r--r--services/gitdiff/gitdiff.go33
1 files changed, 2 insertions, 31 deletions
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index 97daadbc67..37dc0e114d 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -1417,37 +1417,8 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
}
diff.Start = opts.SkipTo
- var checker *git.CheckAttributeReader
-
- if git.CheckGitVersionAtLeast("1.7.8") == nil {
- indexFilename, worktree, deleteTemporaryFile, err := gitRepo.ReadTreeToTemporaryIndex(opts.AfterCommitID)
- if err == nil {
- defer deleteTemporaryFile()
-
- checker = &git.CheckAttributeReader{
- Attributes: []string{"linguist-vendored", "linguist-generated", "linguist-language", "gitlab-language"},
- Repo: gitRepo,
- IndexFile: indexFilename,
- WorkTree: worktree,
- }
- ctx, cancel := context.WithCancel(gitRepo.Ctx)
- if err := checker.Init(ctx); err != nil {
- log.Error("Unable to open checker for %s. Error: %v", opts.AfterCommitID, err)
- } else {
- go func() {
- err := checker.Run()
- if err != nil && err != ctx.Err() {
- log.Error("Unable to open checker for %s. Error: %v", opts.AfterCommitID, err)
- }
- cancel()
- }()
- }
- defer func() {
- _ = checker.Close()
- cancel()
- }()
- }
- }
+ checker, deferable := gitRepo.CheckAttributeReader(opts.AfterCommitID)
+ defer deferable()
for _, diffFile := range diff.Files {