mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-30 19:15:23 +01:00 
			
		
		
		
	Refactor Git command functions to use WithXXX methods instead of exposing RunOpts. This change simplifies reuse across gitrepo and improves consistency, encapsulation, and maintainability of command options. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			749 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			749 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2019 The Gitea Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package repository
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"fmt"
 | |
| 
 | |
| 	git_model "code.gitea.io/gitea/models/git"
 | |
| 	repo_model "code.gitea.io/gitea/models/repo"
 | |
| 	"code.gitea.io/gitea/modules/gitrepo"
 | |
| )
 | |
| 
 | |
| // UpdateRepoSize updates the repository size, calculating it using getDirectorySize
 | |
| func UpdateRepoSize(ctx context.Context, repo *repo_model.Repository) error {
 | |
| 	size, err := gitrepo.CalcRepositorySize(repo)
 | |
| 	if err != nil {
 | |
| 		return fmt.Errorf("updateSize: %w", err)
 | |
| 	}
 | |
| 
 | |
| 	lfsSize, err := git_model.GetRepoLFSSize(ctx, repo.ID)
 | |
| 	if err != nil {
 | |
| 		return fmt.Errorf("updateSize: GetLFSMetaObjects: %w", err)
 | |
| 	}
 | |
| 
 | |
| 	return repo_model.UpdateRepoSize(ctx, repo.ID, size, lfsSize)
 | |
| }
 |