mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Ignore Sync errors on pipes when doing CheckAttributeReader.CheckPath, fix the hang of git cat-file (#17096)
				
					
				
			* Ignore Sync errors on pipes when doing `CheckAttributeReader.CheckPath` * apply env patch * Drop the Sync and fix a number of issues with the Close function Signed-off-by: Andrew Thornton <art27@cantab.net> * add logs for DBIndexer and CheckPath * Fix some more closing bugs Signed-off-by: Andrew Thornton <art27@cantab.net> * Add test case for language_stats Signed-off-by: Andrew Thornton <art27@cantab.net> * Update modules/indexer/stats/db.go Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		
							
								
								
									
										34
									
								
								modules/git/repo_language_stats_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								modules/git/repo_language_stats_test.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
// Copyright 2020 The Gitea Authors. All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a MIT-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
//go:build !gogit
 | 
			
		||||
// +build !gogit
 | 
			
		||||
 | 
			
		||||
package git
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestRepository_GetLanguageStats(t *testing.T) {
 | 
			
		||||
	repoPath := filepath.Join(testReposDir, "language_stats_repo")
 | 
			
		||||
	gitRepo, err := OpenRepository(repoPath)
 | 
			
		||||
	if !assert.NoError(t, err) {
 | 
			
		||||
		t.Fatal()
 | 
			
		||||
	}
 | 
			
		||||
	defer gitRepo.Close()
 | 
			
		||||
 | 
			
		||||
	stats, err := gitRepo.GetLanguageStats("8fee858da5796dfb37704761701bb8e800ad9ef3")
 | 
			
		||||
	if !assert.NoError(t, err) {
 | 
			
		||||
		t.Fatal()
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	assert.EqualValues(t, map[string]int64{
 | 
			
		||||
		"Python": 134,
 | 
			
		||||
		"Java":   112,
 | 
			
		||||
	}, stats)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user