mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from latest commit cache (#32987)
The latest commit cache is currently used only for listing tree files. However, a cold start may take longer than directly invoking the Git command. This PR addresses the issue of slow response times when accessing raw files, improving performance in such scenarios. ```log gitea.log:105521:2024/12/23 08:22:18 ...eb/routing/logger.go:68:func1() [W] router: slow GET /xxxx/xxxxxx/raw/commit/xxxxxxxxxxxxxxxxxxxxxxxxxxx/.editorconfig for 172.18.0.5:53252, elapsed 3526.8ms @ repo/download.go:117(repo.SingleDownload) ```
This commit is contained in:
		| @@ -62,3 +62,14 @@ func (repo *Repository) LsTree(ref string, filenames ...string) ([]string, error | ||||
|  | ||||
| 	return filelist, err | ||||
| } | ||||
|  | ||||
| // GetTreePathLatestCommitID returns the latest commit of a tree path | ||||
| func (repo *Repository) GetTreePathLatestCommit(refName, treePath string) (*Commit, error) { | ||||
| 	stdout, _, err := NewCommand(repo.Ctx, "rev-list", "-1"). | ||||
| 		AddDynamicArguments(refName).AddDashesAndList(treePath). | ||||
| 		RunStdString(&RunOpts{Dir: repo.Path}) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return repo.GetCommit(strings.TrimSpace(stdout)) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user