1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-14 14:37:20 +00:00

Use standalone function to update repository cols (#34811)

Extract `UpdateRepository`
Follow up #34762

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Lunny Xiao
2025-06-27 01:23:21 +08:00
committed by GitHub
parent 750af1c981
commit 0771a79bf0
4 changed files with 31 additions and 49 deletions

View File

@ -41,11 +41,12 @@ func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository,
if err != nil {
return 0, fmt.Errorf("GetObjectFormat: %w", err)
}
_, err = db.GetEngine(ctx).ID(repo.ID).Update(&repo_model.Repository{ObjectFormatName: objFmt.Name()})
if err != nil {
return 0, fmt.Errorf("UpdateRepository: %w", err)
if objFmt.Name() != repo.ObjectFormatName {
repo.ObjectFormatName = objFmt.Name()
if err = repo_model.UpdateRepositoryColsWithAutoTime(ctx, repo, "object_format_name"); err != nil {
return 0, fmt.Errorf("UpdateRepositoryColsWithAutoTime: %w", err)
}
}
repo.ObjectFormatName = objFmt.Name() // keep consistent with db
allBranches := container.Set[string]{}
{