Refactor Branch struct in package modules/git (#33980)

The `Branch` struct in `modules/git` package is unnecessary. We can just
use a `string` to represent a branch
This commit is contained in:
Lunny Xiao
2025-04-02 10:31:32 -07:00
committed by GitHub
parent 285950a222
commit c27d87a9ac
16 changed files with 169 additions and 147 deletions

View File

@ -11,14 +11,14 @@ import (
// GetBranchesByPath returns a branch by its path
// if limit = 0 it will not limit
func GetBranchesByPath(ctx context.Context, repo Repository, skip, limit int) ([]*git.Branch, int, error) {
func GetBranchesByPath(ctx context.Context, repo Repository, skip, limit int) ([]string, int, error) {
gitRepo, err := OpenRepository(ctx, repo)
if err != nil {
return nil, 0, err
}
defer gitRepo.Close()
return gitRepo.GetBranches(skip, limit)
return gitRepo.GetBranchNames(skip, limit)
}
func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (string, error) {