mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-11 01:55:27 +00:00
Merge pull request #182 from ibpl/master-IB#1107754
Incomplete Gitea repository list fixed
This commit is contained in:
commit
831770bad7
1 changed files with 36 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2018 Drone.IO Inc.
|
// 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");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with 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.
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
// This file has been modified by Informatyka Boguslawski sp. z o.o. sp.k.
|
||||||
|
|
||||||
package gitea
|
package gitea
|
||||||
|
|
||||||
|
@ -229,15 +232,41 @@ func (c *client) Repos(u *model.User) ([]*model.Repo, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
all, _, err := client.ListMyRepos(gitea.ListReposOptions{})
|
// Gitea SDK forces us to read repo list paginated.
|
||||||
if err != nil {
|
var page int = 1
|
||||||
return repos, err
|
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 {
|
return repos, nil
|
||||||
repos = append(repos, toRepo(repo, c.PrivateMode))
|
|
||||||
}
|
|
||||||
return repos, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perm returns the user permissions for the named Gitea repository.
|
// Perm returns the user permissions for the named Gitea repository.
|
||||||
|
|
Loading…
Reference in a new issue