mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 11:21:02 +00:00
Fetch all branches from gitea (#1231)
Both repo branch view and manual branch selector were limited to the stock pageSize of gitea client. this add a loop to fetch all branches from gitea
This commit is contained in:
parent
89466646d1
commit
3130a1c523
2 changed files with 22 additions and 7 deletions
|
@ -462,15 +462,29 @@ func (c *Gitea) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]s
|
|||
return nil, err
|
||||
}
|
||||
|
||||
giteaBranches, _, err := client.ListRepoBranches(r.Owner, r.Name, gitea.ListRepoBranchesOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
branches := make([]string, 0)
|
||||
|
||||
page := 1
|
||||
|
||||
for {
|
||||
giteaBranches, _, err := client.ListRepoBranches(r.Owner, r.Name, gitea.ListRepoBranchesOptions{
|
||||
ListOptions: gitea.ListOptions{
|
||||
Page: page,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(giteaBranches) > 0 {
|
||||
for _, branch := range giteaBranches {
|
||||
branches = append(branches, branch.Name)
|
||||
}
|
||||
page++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
branches := make([]string, 0)
|
||||
for _, branch := range giteaBranches {
|
||||
branches = append(branches, branch.Name)
|
||||
}
|
||||
return branches, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ type Remote interface {
|
|||
Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error
|
||||
|
||||
// Branches returns the names of all branches for the named repository.
|
||||
// TODO: Add proper pagination handling and remove workaround in gitea remote
|
||||
Branches(ctx context.Context, u *model.User, r *model.Repo) ([]string, error)
|
||||
|
||||
// BranchHead returns the sha of the head (lastest commit) of the specified branch
|
||||
|
|
Loading…
Reference in a new issue