1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-03 00:45:22 +02:00

Make "sync branch" also sync object format and add tests (#30878)

(cherry picked from commit 9c08637eae8c3a44d15e62d85144e07ae9dabbec)
This commit is contained in:
wxiaoguang 2024-05-07 01:02:30 +08:00 committed by Earl Warren
parent eb4c6f3f09
commit 8cb8547532
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 45 additions and 27 deletions

View file

@ -5,6 +5,7 @@ package repository
import (
"context"
"fmt"
"code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
@ -36,6 +37,15 @@ func SyncRepoBranches(ctx context.Context, repoID, doerID int64) (int64, error)
}
func SyncRepoBranchesWithRepo(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, doerID int64) (int64, error) {
objFmt, err := gitRepo.GetObjectFormat()
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)
}
allBranches := container.Set[string]{}
{
branches, _, err := gitRepo.GetBranchNames(0, 0)