mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 08:06:52 +02:00
Merge pull request #182 from ibpl/master-IB#1107754
Incomplete Gitea repository list fixed
This commit is contained in:
commit
831770bad7
@ -1,4 +1,5 @@
|
||||
// Copyright 2018 Drone.IO Inc.
|
||||
// Copyright 2021 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -11,6 +12,8 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||
|
||||
package gitea
|
||||
|
||||
@ -229,15 +232,41 @@ func (c *client) Repos(u *model.User) ([]*model.Repo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
all, _, err := client.ListMyRepos(gitea.ListReposOptions{})
|
||||
if err != nil {
|
||||
return repos, err
|
||||
// Gitea SDK forces us to read repo list paginated.
|
||||
var page int = 1
|
||||
for {
|
||||
all, _, err := client.ListMyRepos(
|
||||
gitea.ListReposOptions{
|
||||
ListOptions: gitea.ListOptions{
|
||||
Page: page,
|
||||
PageSize: 50, // Gitea SDK limit per page.
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
// Gitea SDK does not return error when asking for
|
||||
// non existing repos page (empty list is returned)
|
||||
// so this should be safe.
|
||||
if err != nil {
|
||||
return repos, err
|
||||
}
|
||||
|
||||
for _, repo := range all {
|
||||
repos = append(repos, toRepo(repo, c.PrivateMode))
|
||||
}
|
||||
|
||||
// Check if no more repos are available; we don't test len(all) < 50
|
||||
// because of Gitea SDK bug https://gitea.com/gitea/go-sdk/issues/507.
|
||||
if len(all) == 0 {
|
||||
// Empty page returned - finish loop.
|
||||
break
|
||||
} else {
|
||||
// Last page was not empty so more repos may be available - continue loop.
|
||||
page = page + 1
|
||||
}
|
||||
}
|
||||
|
||||
for _, repo := range all {
|
||||
repos = append(repos, toRepo(repo, c.PrivateMode))
|
||||
}
|
||||
return repos, err
|
||||
return repos, nil
|
||||
}
|
||||
|
||||
// Perm returns the user permissions for the named Gitea repository.
|
||||
|
Loading…
Reference in New Issue
Block a user