Fix page and missing return on unadopted repos API (#18848) (#18927)

* Fix page and missing return on unadopted repos API

Page must be 1 if it's not specified and it should return after sending an internal server error.

* Allow ignore pages
This commit is contained in:
qwerty287 2022-02-27 13:18:23 +01:00 committed by GitHub
parent 4fb718d405
commit 054bc55a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 3 deletions

View File

@ -445,7 +445,6 @@ func TestAPIRepoTransfer(t *testing.T) {
expectedStatus int
}{
// Disclaimer for test story: "user1" is an admin, "user2" is normal user and part of in owner team of org "user3"
// Transfer to a user with teams in another org should fail
{ctxUserID: 1, newOwner: "user3", teams: &[]int64{5}, expectedStatus: http.StatusForbidden},
// Transfer to a user with non-existent team IDs should fail

View File

@ -61,7 +61,6 @@ type Version struct {
// update minDBVersion accordingly
var migrations = []Migration{
// Gitea 1.5.0 ends at v69
// v70 -> v71
NewMigration("add issue_dependencies", addIssueDependencies),
// v71 -> v72

View File

@ -11,8 +11,8 @@ import (
"strings"
"code.gitea.io/gitea/modules/timeutil"
"github.com/tstranex/u2f"
"github.com/tstranex/u2f"
"xorm.io/xorm"
"xorm.io/xorm/schemas"
)

View File

@ -8,6 +8,7 @@ import (
"testing"
"code.gitea.io/gitea/modules/timeutil"
"github.com/stretchr/testify/assert"
"xorm.io/xorm/schemas"
)

View File

@ -43,9 +43,13 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
// "$ref": "#/responses/forbidden"
listOptions := utils.GetListOptions(ctx)
if listOptions.Page == 0 {
listOptions.Page = 1
}
repoNames, count, err := repo_service.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
if err != nil {
ctx.InternalServerError(err)
return
}
ctx.SetTotalCountHeader(int64(count))