diff --git a/go.mod b/go.mod index ed6d991b5f..a03548412e 100644 --- a/go.mod +++ b/go.mod @@ -117,6 +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 v1.0.1-0.20240122075607-5d314b108abb mvdan.cc/xurls/v2 v2.5.0 strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 xorm.io/builder v0.3.13 @@ -204,6 +205,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.6.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/go-tpm v0.9.0 // indirect github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 // indirect diff --git a/go.sum b/go.sum index ec43f6aa0f..d44888c05e 100644 --- a/go.sum +++ b/go.sum @@ -1291,6 +1291,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.20240122075607-5d314b108abb h1:kS8Jkycu2kggyVggjxC7I24iyDLOB2WqAJ8DlV21Fis= +lab.forgefriends.org/friendlyforgeformat/gof3 v1.0.1-0.20240122075607-5d314b108abb/go.mod h1:LxfG8cikPNzmy77CCYM4b9t/NbFefGJ1rUZujqDNa8Y= lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw= diff --git a/services/f3/driver/main.go b/services/f3/driver/main.go new file mode 100644 index 0000000000..ae034df1a9 --- /dev/null +++ b/services/f3/driver/main.go @@ -0,0 +1,15 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package driver + +import ( + "lab.forgefriends.org/friendlyforgeformat/gof3/options" + f3_tree "lab.forgefriends.org/friendlyforgeformat/gof3/tree/f3" +) + +func init() { + f3_tree.RegisterForgeFactory(Name, newTreeDriver) + options.RegisterFactory(Name, newOptions) +} diff --git a/services/f3/driver/main_test.go b/services/f3/driver/main_test.go new file mode 100644 index 0000000000..48f755a8ef --- /dev/null +++ b/services/f3/driver/main_test.go @@ -0,0 +1,26 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package driver + +import ( + "testing" + + _ "code.gitea.io/gitea/models" + _ "code.gitea.io/gitea/models/actions" + _ "code.gitea.io/gitea/models/activities" + _ "code.gitea.io/gitea/models/perm/access" + + "code.gitea.io/gitea/models/unittest" + + "github.com/stretchr/testify/assert" +) + +func TestF3(t *testing.T) { + assert.NoError(t, unittest.PrepareTestDatabase()) +} + +func TestMain(m *testing.M) { + unittest.MainTest(m) +} diff --git a/services/f3/driver/name.go b/services/f3/driver/name.go new file mode 100644 index 0000000000..de5e359817 --- /dev/null +++ b/services/f3/driver/name.go @@ -0,0 +1,7 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package driver + +const Name = "internal_forgejo" diff --git a/services/f3/driver/options.go b/services/f3/driver/options.go new file mode 100644 index 0000000000..3ab75126d6 --- /dev/null +++ b/services/f3/driver/options.go @@ -0,0 +1,19 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package driver + +import ( + "net/http" + + forgejo_options "code.gitea.io/gitea/services/f3/driver/options" + "lab.forgefriends.org/friendlyforgeformat/gof3/options" +) + +func newOptions() options.Interface { + o := &forgejo_options.Options{} + o.SetName(Name) + o.SetNewMigrationHTTPClient(func() *http.Client { return &http.Client{} }) + return o +} diff --git a/services/f3/driver/options/options.go b/services/f3/driver/options/options.go new file mode 100644 index 0000000000..b32fee3e71 --- /dev/null +++ b/services/f3/driver/options/options.go @@ -0,0 +1,29 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package options + +import ( + "net/http" + + "lab.forgefriends.org/friendlyforgeformat/gof3/options" + "lab.forgefriends.org/friendlyforgeformat/gof3/options/logger" +) + +type NewMigrationHTTPClientFun func() *http.Client + +type Options struct { + options.Options + logger.OptionsLogger + + NewMigrationHTTPClient NewMigrationHTTPClientFun +} + +func (o *Options) GetNewMigrationHTTPClient() NewMigrationHTTPClientFun { + return o.NewMigrationHTTPClient +} + +func (o *Options) SetNewMigrationHTTPClient(fun NewMigrationHTTPClientFun) { + o.NewMigrationHTTPClient = fun +} diff --git a/services/f3/driver/tree.go b/services/f3/driver/tree.go new file mode 100644 index 0000000000..6c91fd6409 --- /dev/null +++ b/services/f3/driver/tree.go @@ -0,0 +1,29 @@ +// Copyright Earl Warren +// Copyright Loïc Dachary +// SPDX-License-Identifier: MIT + +package driver + +import ( + forgejo_options "code.gitea.io/gitea/services/f3/driver/options" + "lab.forgefriends.org/friendlyforgeformat/gof3/tree/generic" +) + +type treeDriver struct { + generic.NullTreeDriver + + options *forgejo_options.Options +} + +func (o *treeDriver) Init() { + o.NullTreeDriver.Init() +} + +func newTreeDriver(tree generic.TreeInterface, anyOptions any) generic.TreeDriverInterface { + driver := &treeDriver{ + options: anyOptions.(*forgejo_options.Options), + } + driver.SetTree(tree) + driver.Init() + return driver +}