Skip to content

Commit 61302eb

Browse files
committed
F3: Gitea driver and CLI
user, topic, project, label, milestone, repository, pull_request, release, asset, comment, reaction, review providers Signed-off-by: Earl Warren <[email protected]>
1 parent af849ac commit 61302eb

File tree

27 files changed

+2782
-6
lines changed

27 files changed

+2782
-6
lines changed

.golangci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ issues:
9898
- gosec
9999
- unparam
100100
- staticcheck
101+
- path: services/f3/driver/driver.go
102+
linters:
103+
- typecheck
101104
- path: models/migrations/v
102105
linters:
103106
- gocyclo

cmd/f3.go

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package cmd
6+
7+
import (
8+
"context"
9+
"fmt"
10+
11+
user_model "code.gitea.io/gitea/models/user"
12+
"code.gitea.io/gitea/modules/git"
13+
"code.gitea.io/gitea/services/f3/util"
14+
"lab.forgefriends.org/friendlyforgeformat/gof3"
15+
f3_format "lab.forgefriends.org/friendlyforgeformat/gof3/format"
16+
17+
"github.com/urfave/cli"
18+
)
19+
20+
var CmdF3 = cli.Command{
21+
Name: "f3",
22+
Usage: "Friendly Forge Format (F3) format export/import.",
23+
Description: "Import or export a repository from or to the Friendly Forge Format (F3) format.",
24+
Action: runF3,
25+
Flags: []cli.Flag{
26+
cli.StringFlag{
27+
Name: "directory",
28+
Value: "./f3",
29+
Usage: "Path of the directory where the F3 dump is stored",
30+
},
31+
cli.StringFlag{
32+
Name: "user",
33+
Value: "",
34+
Usage: "The name of the user who owns the repository",
35+
},
36+
cli.StringFlag{
37+
Name: "repository",
38+
Value: "",
39+
Usage: "The name of the repository",
40+
},
41+
cli.BoolFlag{
42+
Name: "no-pull-request",
43+
Usage: "Do not dump pull requests",
44+
},
45+
cli.BoolFlag{
46+
Name: "import",
47+
Usage: "Import from the directory",
48+
},
49+
cli.BoolFlag{
50+
Name: "export",
51+
Usage: "Export to the directory",
52+
},
53+
},
54+
}
55+
56+
func runF3(ctx *cli.Context) error {
57+
stdCtx, cancel := installSignals()
58+
defer cancel()
59+
60+
if err := initDB(stdCtx); err != nil {
61+
return err
62+
}
63+
64+
if err := git.InitSimple(stdCtx); err != nil {
65+
return err
66+
}
67+
68+
return RunF3(stdCtx, ctx)
69+
}
70+
71+
func RunF3(stdCtx context.Context, ctx *cli.Context) error {
72+
doer, err := user_model.GetAdminUser()
73+
if err != nil {
74+
return err
75+
}
76+
77+
features := gof3.AllFeatures
78+
if ctx.Bool("no-pull-request") {
79+
features.PullRequests = false
80+
}
81+
82+
gitea := util.GiteaForgeRoot(stdCtx, features, doer)
83+
f3 := util.F3ForgeRoot(stdCtx, features, ctx.String("directory"))
84+
85+
if ctx.Bool("export") {
86+
gitea.Forge.Users.List()
87+
user := gitea.Forge.Users.GetFromFormat(&f3_format.User{UserName: ctx.String("user")})
88+
if user.IsNil() {
89+
return fmt.Errorf("%s is not a known user", ctx.String("user"))
90+
}
91+
92+
user.Projects.List()
93+
project := user.Projects.GetFromFormat(&f3_format.Project{Name: ctx.String("repository")})
94+
if project.IsNil() {
95+
return fmt.Errorf("%s/%s is not a known repository", ctx.String("user"), ctx.String("repository"))
96+
}
97+
98+
f3.Forge.Mirror(gitea.Forge, user, project)
99+
fmt.Println("exported")
100+
} else if ctx.Bool("import") {
101+
gitea.Forge.Mirror(f3.Forge)
102+
fmt.Println("imported")
103+
} else {
104+
return fmt.Errorf("either --import or --export must be specified")
105+
}
106+
107+
return nil
108+
}

custom/conf/app.example.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,15 @@ ROUTER = console
22942294
;; If a domain is allowed by ALLOWED_DOMAINS, this option will be ignored.
22952295
;ALLOW_LOCALNETWORKS = false
22962296

2297+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2298+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2299+
;[F3]
2300+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2301+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2302+
;;
2303+
;; Enable/Disable Friendly Forge Format (F3)
2304+
;ENABLED = true
2305+
22972306
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22982307
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22992308
;[federation]

go.mod

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b
7-
code.gitea.io/sdk/gitea v0.15.1
7+
code.gitea.io/sdk/gitea v0.15.1-0.20220915214501-aef4e5e2bd47
88
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
99
gitea.com/go-chi/binding v0.0.0-20220309004920-114340dabecb
1010
gitea.com/go-chi/cache v0.2.0
@@ -104,6 +104,7 @@ require (
104104
gopkg.in/ini.v1 v1.67.0
105105
gopkg.in/yaml.v2 v2.4.0
106106
gopkg.in/yaml.v3 v3.0.1
107+
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20220928084330-fe2f884e84a0
107108
mvdan.cc/xurls/v2 v2.4.0
108109
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
109110
xorm.io/builder v0.3.11
@@ -159,6 +160,7 @@ require (
159160
github.com/couchbase/goutils v0.0.0-20210118111533-e33d3ffb5401 // indirect
160161
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
161162
github.com/davecgh/go-spew v1.1.1 // indirect
163+
github.com/davidmz/go-pageant v1.0.2 // indirect
162164
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
163165
github.com/dlclark/regexp2 v1.7.0 // indirect
164166
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
@@ -194,6 +196,7 @@ require (
194196
github.com/golang/snappy v0.0.4 // indirect
195197
github.com/google/btree v1.0.1 // indirect
196198
github.com/google/certificate-transparency-go v1.1.2-0.20210511102531-373a877eec92 // indirect
199+
github.com/google/go-cmp v0.5.8 // indirect
197200
github.com/google/go-querystring v1.1.0 // indirect
198201
github.com/gorilla/css v1.0.0 // indirect
199202
github.com/gorilla/handlers v1.5.1 // indirect
@@ -284,6 +287,7 @@ require (
284287
go.uber.org/atomic v1.10.0 // indirect
285288
go.uber.org/multierr v1.8.0 // indirect
286289
go.uber.org/zap v1.23.0 // indirect
290+
golang.org/x/exp v0.0.0-20220516143420-24438e51023a // indirect
287291
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
288292
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
289293
google.golang.org/appengine v1.6.7 // indirect

go.sum

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,11 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
6464
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
6565
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
6666
cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y=
67-
code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
6867
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b h1:uv9a8eGSdQ8Dr4HyUcuHFfDsk/QuwO+wf+Y99RYdxY0=
6968
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
7069
code.gitea.io/sdk/gitea v0.11.3/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
71-
code.gitea.io/sdk/gitea v0.15.1 h1:WJreC7YYuxbn0UDaPuWIe/mtiNKTvLN8MLkaw71yx/M=
72-
code.gitea.io/sdk/gitea v0.15.1/go.mod h1:klY2LVI3s3NChzIk/MzMn7G1FHrfU7qd63iSMVoHRBA=
70+
code.gitea.io/sdk/gitea v0.15.1-0.20220915214501-aef4e5e2bd47 h1:e9J9QdBk4NbdskZyGmJcaUGC/agG0UHMGyMrjgPb+6Q=
71+
code.gitea.io/sdk/gitea v0.15.1-0.20220915214501-aef4e5e2bd47/go.mod h1:aRmrQC3CAHdJAU1LQt0C9zqzqI8tUB/5oQtNE746aYE=
7372
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570 h1:TXbikPqa7YRtfU9vS6QJBg77pUvbEb6StRdZO8t1bEY=
7473
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570/go.mod h1:IIAjsijsd8q1isWX8MACefDEgTQslQ4stk2AeeTt3kM=
7574
contrib.go.opencensus.io/exporter/aws v0.0.0-20181029163544-2befc13012d0/go.mod h1:uu1P0UCM/6RbsMrgPa98ll8ZcHM858i/AD06a9aLRCA=
@@ -377,6 +376,8 @@ github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2
377376
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
378377
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
379378
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
379+
github.com/davidmz/go-pageant v1.0.2 h1:bPblRCh5jGU+Uptpz6LgMZGD5hJoOt7otgT454WvHn0=
380+
github.com/davidmz/go-pageant v1.0.2/go.mod h1:P2EDDnMqIwG5Rrp05dTRITj9z2zpGcD9efWSkTNKLIE=
380381
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
381382
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE=
382383
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
@@ -489,6 +490,7 @@ github.com/go-enry/go-enry/v2 v2.8.2 h1:uiGmC+3K8sVd/6DOe2AOJEOihJdqda83nPyJNtMR
489490
github.com/go-enry/go-enry/v2 v2.8.2/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ=
490491
github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo=
491492
github.com/go-enry/go-oniguruma v1.2.1/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4=
493+
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
492494
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e h1:oRq/fiirun5HqlEWMLIcDmLpIELlG4iGbd0s8iqgPi8=
493495
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
494496
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
@@ -1600,12 +1602,14 @@ golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWP
16001602
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
16011603
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
16021604
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
1605+
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
16031606
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
16041607
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
16051608
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
16061609
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
16071610
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
16081611
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
1612+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
16091613
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
16101614
golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
16111615
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A=
@@ -1621,6 +1625,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
16211625
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
16221626
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
16231627
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
1628+
golang.org/x/exp v0.0.0-20220516143420-24438e51023a h1:tiLLxEjKNE6Hrah/Dp/cyHvsyjDLcMFSocOHO5XDmOM=
1629+
golang.org/x/exp v0.0.0-20220516143420-24438e51023a/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
16241630
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
16251631
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
16261632
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -2254,6 +2260,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
22542260
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
22552261
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
22562262
honnef.co/go/tools v0.1.4/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
2263+
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20220928084330-fe2f884e84a0 h1:5Vns5nMBUjMAIkVrTKsZkJ9AH6UCeBj5An8yeMAxVa4=
2264+
lab.forgefriends.org/friendlyforgeformat/gof3 v0.0.0-20220928084330-fe2f884e84a0/go.mod h1:v2t/aa0w224NzBcx1mdzuxJSRWPcaaanQRhV43v7+yw=
22572265
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
22582266
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
22592267
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ arguments - which can alternatively be run by running the subcommand web.`
7575
cmd.CmdDocs,
7676
cmd.CmdDumpRepository,
7777
cmd.CmdRestoreRepository,
78+
cmd.CmdF3,
7879
}
7980
// Now adjust these commands to add our global configuration options
8081

models/repo/topic.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ func GetRepoTopicByName(ctx context.Context, repoID int64, topicName string) (*T
223223
return nil, err
224224
}
225225

226+
// GetRepoTopicByID retrieves topic from ID for a repo if it exist
227+
func GetRepoTopicByID(ctx context.Context, repoID, topicID int64) (*Topic, error) {
228+
cond := builder.NewCond()
229+
var topic Topic
230+
cond = cond.And(builder.Eq{"repo_topic.repo_id": repoID}).And(builder.Eq{"topic.id": topicID})
231+
sess := db.GetEngine(ctx).Table("topic").Where(cond)
232+
sess.Join("INNER", "repo_topic", "repo_topic.topic_id = topic.id")
233+
if has, err := sess.Select("topic.*").Get(&topic); err != nil {
234+
return nil, err
235+
} else if !has {
236+
return nil, ErrTopicNotExist{""}
237+
}
238+
return &topic, nil
239+
}
240+
226241
// AddTopic adds a topic name to a repository (if it does not already have it)
227242
func AddTopic(repoID int64, topicName string) (*Topic, error) {
228243
ctx, committer, err := db.TxContext()

modules/convert/pull_review.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func ToPullReviewCommentList(ctx context.Context, review *issues_model.Review, d
101101
Path: comment.TreePath,
102102
CommitID: comment.CommitSHA,
103103
OrigCommitID: comment.OldRef,
104-
DiffHunk: patch2diff(comment.Patch),
104+
DiffHunk: Patch2diff(comment.Patch),
105105
HTMLURL: comment.HTMLURL(),
106106
HTMLPullURL: review.Issue.HTMLURL(),
107107
}
@@ -118,7 +118,7 @@ func ToPullReviewCommentList(ctx context.Context, review *issues_model.Review, d
118118
return apiComments, nil
119119
}
120120

121-
func patch2diff(patch string) string {
121+
func Patch2diff(patch string) string {
122122
split := strings.Split(patch, "\n@@")
123123
if len(split) == 2 {
124124
return "@@" + split[1]

modules/setting/f3.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package setting
6+
7+
import (
8+
"code.gitea.io/gitea/modules/log"
9+
)
10+
11+
// Friendly Forge Format (F3) settings
12+
var (
13+
F3 = struct {
14+
Enabled bool
15+
}{
16+
Enabled: true,
17+
}
18+
)
19+
20+
func newF3Service() {
21+
if err := Cfg.Section("F3").MapTo(&F3); err != nil {
22+
log.Fatal("Failed to map F3 settings: %v", err)
23+
}
24+
}

modules/setting/setting.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ func NewServices() {
12991299
newProject()
13001300
newMimeTypeMap()
13011301
newFederationService()
1302+
newF3Service()
13021303
}
13031304

13041305
// NewServicesForInstall initializes the services for install

0 commit comments

Comments
 (0)