Merge pull request '[F3] update gof3' (#1147) from dachary/forgejo:wip-f3-cli into forgejo-f3
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/1147
This commit is contained in:
commit
6f571fba30
6 changed files with 45 additions and 45 deletions
|
@ -12,7 +12,7 @@ import (
|
|||
"code.gitea.io/gitea/services/f3/util"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3"
|
||||
f3_types "lab.forgefriends.org/friendlyforgeformat/gof3/config/types"
|
||||
f3_common "lab.forgefriends.org/friendlyforgeformat/gof3/forges/common"
|
||||
f3_format "lab.forgefriends.org/friendlyforgeformat/gof3/format"
|
||||
)
|
||||
|
@ -90,7 +90,7 @@ func RunF3(stdCtx context.Context, ctx *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
features := gof3.AllFeatures
|
||||
features := f3_types.AllFeatures
|
||||
if ctx.Bool("no-pull-request") {
|
||||
features.PullRequests = false
|
||||
}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -117,7 +117,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 v0.0.0-20230701182935-ce3394d54c1e
|
||||
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20230727095825-ce0c3d1c91ae
|
||||
mvdan.cc/xurls/v2 v2.5.0
|
||||
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
|
||||
xorm.io/builder v0.3.13
|
||||
|
@ -291,7 +291,7 @@ require (
|
|||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20220516143420-24438e51023a // indirect
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1143,8 +1143,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
|
|||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20220516143420-24438e51023a h1:tiLLxEjKNE6Hrah/Dp/cyHvsyjDLcMFSocOHO5XDmOM=
|
||||
golang.org/x/exp v0.0.0-20220516143420-24438e51023a/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.9.0 h1:QrzfX26snvCM20hIhBwuHI/ThTg18b/+kcKdXHvnR+g=
|
||||
|
@ -1573,8 +1573,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 v0.0.0-20230701182935-ce3394d54c1e h1:dcD+UGLSrgeHYyEWZ+1mZvxQ2BXKyEhjhHcB7a6XgeA=
|
||||
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20230701182935-ce3394d54c1e/go.mod h1:yIlQydnn+pym6OH20iQ7fbe2TjLfnlOTtEOqvjFaC70=
|
||||
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20230727095825-ce0c3d1c91ae h1:O5colcyXVMuo4iVaXmBux8wa+HROJfhFOnA/TLKXIew=
|
||||
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20230727095825-ce0c3d1c91ae/go.mod h1:TcKaEsgVihjAjw290iDvvirCT0P+DZNpzc0ZgNgy3E4=
|
||||
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=
|
||||
|
|
|
@ -9,14 +9,14 @@ import (
|
|||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/services/migrations"
|
||||
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3"
|
||||
f3_types "lab.forgefriends.org/friendlyforgeformat/gof3/config/types"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3/forges/common"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3/forges/driver"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3/format"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
gof3.Options
|
||||
f3_types.Options
|
||||
|
||||
AuthenticationSource int64
|
||||
Doer *user_model.User
|
||||
|
@ -31,11 +31,11 @@ func (o *Forgejo) GetPerPage() int {
|
|||
return o.perPage
|
||||
}
|
||||
|
||||
func (o *Forgejo) GetOptions() gof3.OptionsInterface {
|
||||
func (o *Forgejo) GetOptions() f3_types.OptionsInterface {
|
||||
return o.options
|
||||
}
|
||||
|
||||
func (o *Forgejo) SetOptions(options gof3.OptionsInterface) {
|
||||
func (o *Forgejo) SetOptions(options f3_types.OptionsInterface) {
|
||||
var ok bool
|
||||
o.options, ok = options.(*Options)
|
||||
if !ok {
|
||||
|
@ -43,11 +43,11 @@ func (o *Forgejo) SetOptions(options gof3.OptionsInterface) {
|
|||
}
|
||||
}
|
||||
|
||||
func (o *Forgejo) GetLogger() *gof3.Logger {
|
||||
func (o *Forgejo) GetLogger() *f3_types.Logger {
|
||||
return o.GetOptions().GetLogger()
|
||||
}
|
||||
|
||||
func (o *Forgejo) Init(options gof3.OptionsInterface) {
|
||||
func (o *Forgejo) Init(options f3_types.OptionsInterface) {
|
||||
o.SetOptions(options)
|
||||
o.perPage = setting.ItemsPerPage
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (o *Forgejo) GetAuthenticationSource() int64 {
|
|||
return o.options.AuthenticationSource
|
||||
}
|
||||
|
||||
func (o *Forgejo) GetNewMigrationHTTPClient() gof3.NewMigrationHTTPClientFun {
|
||||
func (o *Forgejo) GetNewMigrationHTTPClient() f3_types.NewMigrationHTTPClientFun {
|
||||
return migrations.NewMigrationHTTPClient
|
||||
}
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@ import (
|
|||
base "code.gitea.io/gitea/modules/migration"
|
||||
"code.gitea.io/gitea/services/f3/driver"
|
||||
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3"
|
||||
f3_types "lab.forgefriends.org/friendlyforgeformat/gof3/config/types"
|
||||
f3_forges "lab.forgefriends.org/friendlyforgeformat/gof3/forges"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3/forges/f3"
|
||||
)
|
||||
|
||||
func ToF3Logger(messenger base.Messenger) gof3.Logger {
|
||||
func ToF3Logger(messenger base.Messenger) f3_types.Logger {
|
||||
if messenger == nil {
|
||||
messenger = func(message string, args ...interface{}) {
|
||||
log.Info("Message: "+message, args...)
|
||||
}
|
||||
}
|
||||
return gof3.Logger{
|
||||
Message: messenger,
|
||||
return f3_types.Logger{
|
||||
Message: f3_types.LoggerFun(messenger),
|
||||
Trace: log.Trace,
|
||||
Debug: log.Debug,
|
||||
Info: log.Info,
|
||||
|
@ -31,9 +31,9 @@ func ToF3Logger(messenger base.Messenger) gof3.Logger {
|
|||
}
|
||||
}
|
||||
|
||||
func ForgejoForgeRoot(features gof3.Features, doer *user_model.User, authenticationSource int64) *f3_forges.ForgeRoot {
|
||||
func ForgejoForgeRoot(features f3_types.Features, doer *user_model.User, authenticationSource int64) *f3_forges.ForgeRoot {
|
||||
forgeRoot := f3_forges.NewForgeRootFromDriver(&driver.Forgejo{}, &driver.Options{
|
||||
Options: gof3.Options{
|
||||
Options: f3_types.Options{
|
||||
Features: features,
|
||||
Logger: ToF3Logger(nil),
|
||||
},
|
||||
|
@ -43,10 +43,10 @@ func ForgejoForgeRoot(features gof3.Features, doer *user_model.User, authenticat
|
|||
return forgeRoot
|
||||
}
|
||||
|
||||
func F3ForgeRoot(features gof3.Features, directory string) *f3_forges.ForgeRoot {
|
||||
func F3ForgeRoot(features f3_types.Features, directory string) *f3_forges.ForgeRoot {
|
||||
forgeRoot := f3_forges.NewForgeRoot(&f3.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
Directory: directory,
|
||||
},
|
||||
Features: features,
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
"github.com/markbates/goth"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"lab.forgefriends.org/friendlyforgeformat/gof3"
|
||||
f3_types "lab.forgefriends.org/friendlyforgeformat/gof3/config/types"
|
||||
f3_forges "lab.forgefriends.org/friendlyforgeformat/gof3/forges"
|
||||
f3_common "lab.forgefriends.org/friendlyforgeformat/gof3/forges/common"
|
||||
f3_f3 "lab.forgefriends.org/friendlyforgeformat/gof3/forges/f3"
|
||||
|
@ -48,11 +48,11 @@ func TestF3Mirror(t *testing.T) {
|
|||
//
|
||||
fixtureNewF3Forge := func(t f3_tests.TestingT, user *format.User, tmpDir string) *f3_forges.ForgeRoot {
|
||||
root := f3_forges.NewForgeRoot(&f3_f3.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
Directory: tmpDir,
|
||||
},
|
||||
Features: gof3.AllFeatures,
|
||||
Features: f3_types.AllFeatures,
|
||||
Logger: util.ToF3Logger(nil),
|
||||
},
|
||||
Remap: true,
|
||||
|
@ -80,7 +80,7 @@ func TestF3Mirror(t *testing.T) {
|
|||
//
|
||||
doer, err := user_model.GetAdminUser(context.Background())
|
||||
assert.NoError(t, err)
|
||||
forgejoLocal := util.ForgejoForgeRoot(gof3.AllFeatures, doer, 0)
|
||||
forgejoLocal := util.ForgejoForgeRoot(f3_types.AllFeatures, doer, 0)
|
||||
options := f3_common.NewMirrorOptionsRecurse()
|
||||
forgejoLocal.Forge.Mirror(context.Background(), fixture.Forge, options)
|
||||
|
||||
|
@ -89,12 +89,12 @@ func TestF3Mirror(t *testing.T) {
|
|||
//
|
||||
adminUsername := "user1"
|
||||
forgejoAPI := f3_forges.NewForgeRootFromDriver(&f3_forgejo.Forgejo{}, &f3_forgejo.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
URL: setting.AppURL,
|
||||
Directory: t.TempDir(),
|
||||
},
|
||||
Features: gof3.AllFeatures,
|
||||
Features: f3_types.AllFeatures,
|
||||
},
|
||||
AuthToken: getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin, auth_model.AccessTokenScopeAll),
|
||||
})
|
||||
|
@ -198,11 +198,11 @@ func TestF3UserMappingExisting(t *testing.T) {
|
|||
log.Debug("Step 1: create a fixture in F3")
|
||||
fixtureNewF3Forge := func(t f3_tests.TestingT, user *format.User, tmpDir string) *f3_forges.ForgeRoot {
|
||||
root := f3_forges.NewForgeRoot(&f3_f3.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
Directory: tmpDir,
|
||||
},
|
||||
Features: gof3.AllFeatures,
|
||||
Features: f3_types.AllFeatures,
|
||||
Logger: util.ToF3Logger(nil),
|
||||
},
|
||||
Remap: true,
|
||||
|
@ -236,19 +236,19 @@ func TestF3UserMappingExisting(t *testing.T) {
|
|||
|
||||
doer, err := user_model.GetAdminUser(context.Background())
|
||||
assert.NoError(t, err)
|
||||
forgejoLocal := util.ForgejoForgeRoot(gof3.AllFeatures, doer, gitlab.ID)
|
||||
forgejoLocal := util.ForgejoForgeRoot(f3_types.AllFeatures, doer, gitlab.ID)
|
||||
options := f3_common.NewMirrorOptionsRecurse()
|
||||
forgejoLocal.Forge.Mirror(context.Background(), fixture.Forge, options)
|
||||
|
||||
log.Debug("Step 3: mirror Forgejo into F3")
|
||||
adminUsername := "user1"
|
||||
forgejoAPI := f3_forges.NewForgeRootFromDriver(&f3_forgejo.Forgejo{}, &f3_forgejo.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
URL: setting.AppURL,
|
||||
Directory: t.TempDir(),
|
||||
},
|
||||
Features: gof3.AllFeatures,
|
||||
Features: f3_types.AllFeatures,
|
||||
Logger: util.ToF3Logger(nil),
|
||||
},
|
||||
AuthToken: getUserToken(t, adminUsername, auth_model.AccessTokenScopeWriteAdmin, auth_model.AccessTokenScopeAll),
|
||||
|
@ -286,11 +286,11 @@ func TestF3UserMappingNew(t *testing.T) {
|
|||
log.Debug("Step 1: create a fixture in F3")
|
||||
fixtureNewF3Forge := func(t f3_tests.TestingT, user *format.User, tmpDir string) *f3_forges.ForgeRoot {
|
||||
root := f3_forges.NewForgeRoot(&f3_f3.Options{
|
||||
Options: gof3.Options{
|
||||
Configuration: gof3.Configuration{
|
||||
Options: f3_types.Options{
|
||||
Configuration: f3_types.Configuration{
|
||||
Directory: tmpDir,
|
||||
},
|
||||
Features: gof3.AllFeatures,
|
||||
Features: f3_types.AllFeatures,
|
||||
Logger: util.ToF3Logger(nil),
|
||||
},
|
||||
Remap: true,
|
||||
|
@ -304,7 +304,7 @@ func TestF3UserMappingNew(t *testing.T) {
|
|||
log.Debug("Step 2: mirror F3 into Forgejo")
|
||||
doer, err := user_model.GetAdminUser(context.Background())
|
||||
assert.NoError(t, err)
|
||||
forgejoLocalDestination := util.ForgejoForgeRoot(gof3.AllFeatures, doer, 0)
|
||||
forgejoLocalDestination := util.ForgejoForgeRoot(f3_types.AllFeatures, doer, 0)
|
||||
options := f3_common.NewMirrorOptionsRecurse()
|
||||
forgejoLocalDestination.Forge.Mirror(context.Background(), fixture.Forge, options)
|
||||
|
||||
|
@ -315,8 +315,8 @@ func TestF3UserMappingNew(t *testing.T) {
|
|||
forgejoLocalDestination.Forge.Mirror(context.Background(), fixture.Forge, options)
|
||||
|
||||
log.Debug("Step 4: mirror Forgejo into F3 using the changed name")
|
||||
f3 := util.F3ForgeRoot(gof3.AllFeatures, t.TempDir())
|
||||
forgejoLocalOrigin := util.ForgejoForgeRoot(gof3.AllFeatures, doer, 0)
|
||||
f3 := util.F3ForgeRoot(f3_types.AllFeatures, t.TempDir())
|
||||
forgejoLocalOrigin := util.ForgejoForgeRoot(f3_types.AllFeatures, doer, 0)
|
||||
forgejoLocalOriginUser := forgejoLocalOrigin.Forge.Users.GetFromFormat(context.Background(), &format.User{UserName: otherusername})
|
||||
options = f3_common.NewMirrorOptionsRecurse(forgejoLocalOriginUser)
|
||||
f3.Forge.Mirror(context.Background(), forgejoLocalOrigin.Forge, options)
|
||||
|
|
Loading…
Reference in a new issue