mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 00:20:25 +08:00 
			
		
		
		
	Cache last commit when pushing for big repository (#10109)
* Cache last commit when pushing for big repository * Fix bug * detect force push * Refactor cache push * Finish cache last commit info when push * Some improvements * Fix lint * Remove unused changes * Move pull request test before cache * Fix test mysql Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
		@@ -40,7 +40,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom
 | 
			
		||||
			return nil, nil, err
 | 
			
		||||
		}
 | 
			
		||||
		if len(unHitPaths) > 0 {
 | 
			
		||||
			revs2, err := getLastCommitForPaths(c, treePath, unHitPaths)
 | 
			
		||||
			revs2, err := GetLastCommitForPaths(c, treePath, unHitPaths)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, nil, err
 | 
			
		||||
			}
 | 
			
		||||
@@ -53,7 +53,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		revs, err = getLastCommitForPaths(c, treePath, entryPaths)
 | 
			
		||||
		revs, err = GetLastCommitForPaths(c, treePath, entryPaths)
 | 
			
		||||
	}
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, nil, err
 | 
			
		||||
@@ -170,7 +170,8 @@ func getLastCommitForPathsByCache(commitID, treePath string, paths []string, cac
 | 
			
		||||
	return results, unHitEntryPaths, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func getLastCommitForPaths(c cgobject.CommitNode, treePath string, paths []string) (map[string]*object.Commit, error) {
 | 
			
		||||
// GetLastCommitForPaths returns last commit information
 | 
			
		||||
func GetLastCommitForPaths(c cgobject.CommitNode, treePath string, paths []string) (map[string]*object.Commit, error) {
 | 
			
		||||
	// We do a tree traversal with nodes sorted by commit time
 | 
			
		||||
	heap := binaryheap.NewWith(func(a, b interface{}) int {
 | 
			
		||||
		if a.(*commitAndPaths).commit.CommitTime().Before(b.(*commitAndPaths).commit.CommitTime()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,7 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	lastCommits, err := getLastCommitForPaths(commitNode, "", []string{path})
 | 
			
		||||
	lastCommits, err := GetLastCommitForPaths(commitNode, "", []string{path})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user