mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-09-01 22:59:22 +00:00
Dynamic forge request size (#2622)
and remove checks for gitea 1.18 which is quite old already and shouldn't be used anymore closes https://github.com/woodpecker-ci/woodpecker/issues/1038
This commit is contained in:
@@ -9,6 +9,4 @@
|
|||||||
| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| Event: Pull-Request | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| Event: Deploy | :white_check_mark: | :x: | :x: | :x: |
|
| Event: Deploy | :white_check_mark: | :x: | :x: | :x: |
|
||||||
| [Multiple workflows](../../20-usage/25-workflows.md) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
| [Multiple workflows](../../20-usage/25-workflows.md) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||||
| [when.path filter](../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark:¹ | :white_check_mark: | :x: |
|
| [when.path filter](../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
|
||||||
|
|
||||||
¹ for pull requests at least Gitea version 1.17 is required
|
|
||||||
|
@@ -47,7 +47,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
authorizeTokenURL = "%s/login/oauth/authorize"
|
authorizeTokenURL = "%s/login/oauth/authorize"
|
||||||
accessTokenURL = "%s/login/oauth/access_token"
|
accessTokenURL = "%s/login/oauth/access_token"
|
||||||
perPage = 50
|
defaultPageSize = 50
|
||||||
giteaDevVersion = "v1.18.0"
|
giteaDevVersion = "v1.18.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -56,6 +56,7 @@ type Gitea struct {
|
|||||||
ClientID string
|
ClientID string
|
||||||
ClientSecret string
|
ClientSecret string
|
||||||
SkipVerify bool
|
SkipVerify bool
|
||||||
|
pageSize int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opts defines configuration options.
|
// Opts defines configuration options.
|
||||||
@@ -207,7 +208,7 @@ func (c *Gitea) Teams(ctx context.Context, u *model.User) ([]*model.Team, error)
|
|||||||
gitea.ListOrgsOptions{
|
gitea.ListOrgsOptions{
|
||||||
ListOptions: gitea.ListOptions{
|
ListOptions: gitea.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: perPage,
|
PageSize: c.perPage(ctx),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -263,7 +264,7 @@ func (c *Gitea) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error)
|
|||||||
gitea.ListReposOptions{
|
gitea.ListReposOptions{
|
||||||
ListOptions: gitea.ListOptions{
|
ListOptions: gitea.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: perPage,
|
PageSize: c.perPage(ctx),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -621,12 +622,6 @@ func (c *Gitea) getChangedFilesForPR(ctx context.Context, repo *model.Repo, inde
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.CheckServerVersionConstraint(">= 1.18.0") != nil {
|
|
||||||
// version too low
|
|
||||||
log.Debug().Msg("Gitea version does not support getting changed files for PRs")
|
|
||||||
return []string{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return shared_utils.Paginate(func(page int) ([]string, error) {
|
return shared_utils.Paginate(func(page int) ([]string, error) {
|
||||||
giteaFiles, _, err := client.ListPullRequestFiles(repo.Owner, repo.Name, index,
|
giteaFiles, _, err := client.ListPullRequestFiles(repo.Owner, repo.Name, index,
|
||||||
gitea.ListPullRequestFilesOptions{ListOptions: gitea.ListOptions{Page: page}})
|
gitea.ListPullRequestFilesOptions{ListOptions: gitea.ListOptions{Page: page}})
|
||||||
@@ -641,3 +636,19 @@ func (c *Gitea) getChangedFilesForPR(ctx context.Context, repo *model.Repo, inde
|
|||||||
return files, nil
|
return files, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Gitea) perPage(ctx context.Context) int {
|
||||||
|
if c.pageSize == 0 {
|
||||||
|
client, err := c.newClientToken(ctx, "")
|
||||||
|
if err != nil {
|
||||||
|
return defaultPageSize
|
||||||
|
}
|
||||||
|
|
||||||
|
api, _, err := client.GetGlobalAPISettings()
|
||||||
|
if err != nil {
|
||||||
|
return defaultPageSize
|
||||||
|
}
|
||||||
|
c.pageSize = api.MaxResponseItems
|
||||||
|
}
|
||||||
|
return c.pageSize
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user