mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-02 13:39:55 +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
|
@ -462,15 +462,29 @@ func (c *Gitea) Branches(ctx context.Context, u *model.User, r *model.Repo) ([]s
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
giteaBranches, _, err := client.ListRepoBranches(r.Owner, r.Name, gitea.ListRepoBranchesOptions{})
|
branches := make([]string, 0)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
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
|
return branches, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,7 @@ type Remote interface {
|
||||||
Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error
|
Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error
|
||||||
|
|
||||||
// Branches returns the names of all branches for the named repository.
|
// 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)
|
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
|
// BranchHead returns the sha of the head (lastest commit) of the specified branch
|
||||||
|
|
Loading…
Reference in a new issue