diff options
author | Earl Warren <contact@earl-warren.org> | 2024-06-16 13:09:52 +0200 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-06-16 13:33:33 +0200 |
commit | 50afca7961ed330f1ce107a8c9a4f77c90f720d4 (patch) | |
tree | db27b655e2ea0f207db25bfa470f44ed9b986cd6 | |
parent | [FEAT] folding results for repo search (#4134) (diff) | |
download | forgejo-50afca7961ed330f1ce107a8c9a4f77c90f720d4.tar.xz forgejo-50afca7961ed330f1ce107a8c9a4f77c90f720d4.zip |
fix(f3): do not run the F3 CLI if F3 is disabled
-rw-r--r-- | cmd/forgejo/f3.go | 7 | ||||
-rw-r--r-- | modules/setting/f3.go | 4 | ||||
-rw-r--r-- | tests/integration/cmd_forgejo_f3_test.go | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/cmd/forgejo/f3.go b/cmd/forgejo/f3.go index 574c776ded..5a0d0ac036 100644 --- a/cmd/forgejo/f3.go +++ b/cmd/forgejo/f3.go @@ -6,10 +6,12 @@ package forgejo import ( "context" + "errors" "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/services/f3/util" @@ -41,6 +43,11 @@ func SubcmdF3Mirror(ctx context.Context) *cli.Command { } func runMirror(ctx context.Context, c *cli.Context, action cli.ActionFunc) error { + setting.LoadF3Setting() + if !setting.F3.Enabled { + return errors.New("F3 is disabled, it is not ready to be used and is only present for development purposes") + } + var cancel context.CancelFunc if !ContextGetNoInit(ctx) { ctx, cancel = installSignals(ctx) diff --git a/modules/setting/f3.go b/modules/setting/f3.go index 8a66d68fc6..8669b70562 100644 --- a/modules/setting/f3.go +++ b/modules/setting/f3.go @@ -15,6 +15,10 @@ var ( } ) +func LoadF3Setting() { + loadF3From(CfgProvider) +} + func loadF3From(rootCfg ConfigProvider) { if err := rootCfg.Section("F3").MapTo(&F3); err != nil { log.Fatal("Failed to map F3 settings: %v", err) diff --git a/tests/integration/cmd_forgejo_f3_test.go b/tests/integration/cmd_forgejo_f3_test.go index 1d932693cf..5dadcef0a2 100644 --- a/tests/integration/cmd_forgejo_f3_test.go +++ b/tests/integration/cmd_forgejo_f3_test.go @@ -10,6 +10,8 @@ import ( "testing" "code.gitea.io/gitea/cmd/forgejo" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/services/f3/driver/options" "code.gitea.io/gitea/tests" @@ -56,6 +58,7 @@ func runApp(ctx context.Context, args ...string) (string, error) { func TestF3_CmdMirror_LocalForgejo(t *testing.T) { defer tests.PrepareTestEnv(t)() + defer test.MockVariableValue(&setting.F3.Enabled, true)() ctx := context.Background() |