From 1b0db139d68c616270f96382f6f7c8340692f6f7 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 16 Oct 2023 20:33:44 +0200 Subject: [PATCH] [F3] resolve (cherry picked from commit 2acd211536a7b49dc3198d5cf80dcd3c8ff6a837) (cherry picked from commit 704317c24e3969e1240eaeac7fd02aac0225d769) (cherry picked from commit b127296da6742cf1b0380f0779f5dd59d5be34fa) (cherry picked from commit 000b6f823e242f965628f205bcbdeb924b983e56) (cherry picked from commit 7bd1b351390d14c79e5c39a16e720eebe995d307) (cherry picked from commit 6ba434bf2fcea63204f6d6cd4db7521e30f2b564) (cherry picked from commit 5c0826c529d8205f2b303c5a40336de8b905bfa0) (cherry picked from commit 00f7d12512db003f5e2d9267351e46e6d8e1905c) (cherry picked from commit 13550cb0b51b12785a26a227af2bd7226aabb445) (cherry picked from commit 3b16d9e1143a14a5351de51286ac67ec974c47e7) --- go.mod | 6 +++--- go.sum | 8 ++++---- routers/web/auth/oauth.go | 2 +- services/f3/driver/milestone.go | 6 ++---- services/f3/driver/project.go | 4 ++-- services/f3/driver/release.go | 2 +- services/f3/promote.go | 2 +- tests/integration/integration_test.go | 2 +- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index ea7bfb472e..138c701fa4 100644 --- a/go.mod +++ b/go.mod @@ -100,7 +100,7 @@ require ( github.com/tstranex/u2f v1.0.0 github.com/ulikunitz/xz v0.5.11 github.com/urfave/cli/v2 v2.26.0 - github.com/xanzy/go-gitlab v0.95.2 + github.com/xanzy/go-gitlab v0.93.1 github.com/xeipuuv/gojsonschema v1.2.0 github.com/yohcop/openid-go v1.0.1 github.com/yuin/goldmark v1.6.0 @@ -118,7 +118,7 @@ require ( gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/ini.v1 v1.67.0 gopkg.in/yaml.v3 v3.0.1 - lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230917111322-4e5634530d7b + lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20231016193607-59f139e6759e mvdan.cc/xurls/v2 v2.5.0 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 xorm.io/builder v0.3.13 @@ -206,7 +206,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/go-tpm v0.9.0 // indirect github.com/gorilla/css v1.0.1 // indirect diff --git a/go.sum b/go.sum index a78cfae0b6..6eb491c754 100644 --- a/go.sum +++ b/go.sum @@ -959,8 +959,8 @@ github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7Fw github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xanzy/go-gitlab v0.95.2 h1:4p0IirHqEp5f0baK/aQqr4TR57IsD+8e4fuyAA1yi88= -github.com/xanzy/go-gitlab v0.95.2/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI= +github.com/xanzy/go-gitlab v0.93.1 h1:f7J33cw/P9b/8paIOoH0F3H+TFrswvWHs6yUgoTp9LY= +github.com/xanzy/go-gitlab v0.93.1/go.mod h1:5ryv+MnpZStBH8I/77HuQBsMbBGANtVpLWC15qOjWAw= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= @@ -1463,8 +1463,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230917111322-4e5634530d7b h1:ws6llA9HwUA2ofK//7Y/HkV2oaP60M120FFBsHI0G78= -lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20230917111322-4e5634530d7b/go.mod h1:TcKaEsgVihjAjw290iDvvirCT0P+DZNpzc0ZgNgy3E4= +lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20231016193607-59f139e6759e h1:xLOCDcDRZ7VwOqdC0NxA+OdUq2X2piHahNylwkF2uN8= +lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20231016193607-59f139e6759e/go.mod h1:gbekmufZ+PvotlQUCw9OpcMYo4igaWDjyT70FyNGFwc= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 6e133abfca..1246f280ba 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -1291,7 +1291,7 @@ func oAuth2GothUserToUser(ctx go_context.Context, authSource *auth.Source, gothU ExternalID: gothUser.UserID, LoginSourceID: authSource.ID, } - hasUser, err = user_model.GetExternalLogin(request.Context(), externalLoginUser) + hasUser, err = user_model.GetExternalLogin(ctx, externalLoginUser) if err != nil { return nil, err } diff --git a/services/f3/driver/milestone.go b/services/f3/driver/milestone.go index f5aea0fae3..2cb8c4458f 100644 --- a/services/f3/driver/milestone.go +++ b/services/f3/driver/milestone.go @@ -10,7 +10,6 @@ import ( "code.gitea.io/gitea/models/db" issues_model "code.gitea.io/gitea/models/issues" "code.gitea.io/gitea/modules/setting" - api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" "lab.forgefriends.org/friendlyforgeformat/gof3/format" @@ -133,16 +132,15 @@ func (o *MilestoneProvider) FromFormat(ctx context.Context, m *format.Milestone) } func (o *MilestoneProvider) GetObjects(ctx context.Context, user *User, project *Project, page int) []*Milestone { - milestones, _, err := issues_model.GetMilestones(issues_model.GetMilestonesOption{ + milestones, err := db.Find[issues_model.Milestone](ctx, issues_model.FindMilestoneOptions{ ListOptions: db.ListOptions{Page: page, PageSize: o.g.perPage}, RepoID: project.GetID(), - State: api.StateAll, }) if err != nil { panic(fmt.Errorf("error while listing milestones: %v", err)) } - r := util.ConvertMap[*issues_model.Milestone, *Milestone](([]*issues_model.Milestone)(milestones), MilestoneConverter) + r := util.ConvertMap[*issues_model.Milestone, *Milestone](milestones, MilestoneConverter) if o.project != nil { o.project.milestones = util.NewNameIDMap[*Milestone](r) } diff --git a/services/f3/driver/project.go b/services/f3/driver/project.go index 5fb163da48..2b878f2ad7 100644 --- a/services/f3/driver/project.go +++ b/services/f3/driver/project.go @@ -100,7 +100,7 @@ func (o *ProjectProvider) FromFormat(ctx context.Context, p *format.Project) *Pr } func (o *ProjectProvider) GetObjects(ctx context.Context, user *User, page int) []*Project { - repoList, _, err := repo_model.GetUserRepositories(&repo_model.SearchRepoOptions{ + repoList, _, err := repo_model.GetUserRepositories(ctx, &repo_model.SearchRepoOptions{ ListOptions: db.ListOptions{Page: page, PageSize: o.g.perPage}, Actor: &user.User, Private: true, @@ -123,7 +123,7 @@ func (o *ProjectProvider) Get(ctx context.Context, user *User, exemplar *Project if exemplar.GetID() > 0 { project, err = repo_model.GetRepositoryByID(ctx, exemplar.GetID()) } else if exemplar.Name != "" { - project, err = repo_model.GetRepositoryByName(user.GetID(), exemplar.Name) + project, err = repo_model.GetRepositoryByName(ctx, user.GetID(), exemplar.Name) } else { panic("GetID() == 0 and ProjectName == \"\"") } diff --git a/services/f3/driver/release.go b/services/f3/driver/release.go index a666794052..34559af425 100644 --- a/services/f3/driver/release.go +++ b/services/f3/driver/release.go @@ -188,7 +188,7 @@ func (o *ReleaseProvider) Put(ctx context.Context, user *User, project *Project, func (o *ReleaseProvider) Delete(ctx context.Context, user *User, project *Project, release *Release) *Release { m := o.Get(ctx, user, project, release) if !m.IsNil() { - if err := release_service.DeleteReleaseByID(ctx, release.GetID(), o.g.GetDoer(), false); err != nil { + if err := release_service.DeleteReleaseByID(ctx, &project.Repository, &release.Release, o.g.GetDoer(), false); err != nil { panic(err) } } diff --git a/services/f3/promote.go b/services/f3/promote.go index 5a56e83773..0c4b357d2f 100644 --- a/services/f3/promote.go +++ b/services/f3/promote.go @@ -92,7 +92,7 @@ func getF3UserToPromote(ctx context.Context, source *auth_model.Source, loginNam return nil, nil } - userSource, err := auth_model.GetSourceByID(u.LoginSource) + userSource, err := auth_model.GetSourceByID(ctx, u.LoginSource) if err != nil { if auth_model.IsErrSourceNotExist(err) { log.Error("getF3UserToPromote: source id = %v for user %v not found %v", u.LoginSource, u.ID, err) diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 6abed73ab9..e483c8331c 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -281,7 +281,7 @@ func authSourcePayloadGitLabCustom(name string) map[string]string { } func createF3AuthSource(t *testing.T, name, url, matchingSource string) *auth.Source { - assert.NoError(t, auth.CreateSource(&auth.Source{ + assert.NoError(t, auth.CreateSource(context.Background(), &auth.Source{ Type: auth.F3, Name: name, IsActive: true,