Skip to content

Commit 054bc55

Browse files
authored
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
1 parent 4fb718d commit 054bc55

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

integrations/api_repo_test.go

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

models/migrations/migrations.go

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type Version struct {
6161
// update minDBVersion accordingly
6262
var migrations = []Migration{
6363
// Gitea 1.5.0 ends at v69
64-
6564
// v70 -> v71
6665
NewMigration("add issue_dependencies", addIssueDependencies),
6766
// v71 -> v72

models/migrations/v210.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"strings"
1212

1313
"code.gitea.io/gitea/modules/timeutil"
14-
"github.com/tstranex/u2f"
1514

15+
"github.com/tstranex/u2f"
1616
"xorm.io/xorm"
1717
"xorm.io/xorm/schemas"
1818
)

models/migrations/v210_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
"code.gitea.io/gitea/modules/timeutil"
11+
1112
"github.com/stretchr/testify/assert"
1213
"xorm.io/xorm/schemas"
1314
)

routers/api/v1/admin/adopt.go

+4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ func ListUnadoptedRepositories(ctx *context.APIContext) {
4343
// "$ref": "#/responses/forbidden"
4444

4545
listOptions := utils.GetListOptions(ctx)
46+
if listOptions.Page == 0 {
47+
listOptions.Page = 1
48+
}
4649
repoNames, count, err := repo_service.ListUnadoptedRepositories(ctx.FormString("query"), &listOptions)
4750
if err != nil {
4851
ctx.InternalServerError(err)
52+
return
4953
}
5054

5155
ctx.SetTotalCountHeader(int64(count))

0 commit comments

Comments
 (0)