diff --git a/cmd/ftl/cmd_init.go b/cmd/ftl/cmd_init.go index 7ab8c4245f..b643a0dcbb 100644 --- a/cmd/ftl/cmd_init.go +++ b/cmd/ftl/cmd_init.go @@ -126,7 +126,7 @@ var scaffoldFuncs = template.FuncMap{ func updateGitIgnore(dir string) error { gitRoot, ok := internal.GitRoot(dir).Get() if !ok { - gitRoot = "" + return nil } f, err := os.OpenFile(path.Join(gitRoot, ".gitignore"), os.O_RDWR|os.O_CREATE, 0644) //nolint:gosec if err != nil { diff --git a/common/configuration/projectconfig_resolver_test.go b/common/configuration/projectconfig_resolver_test.go index af04a25700..dc5e3eeec5 100644 --- a/common/configuration/projectconfig_resolver_test.go +++ b/common/configuration/projectconfig_resolver_test.go @@ -15,7 +15,7 @@ import ( ) func TestSet(t *testing.T) { - defaultPath, ok := projectconfig.GetDefaultConfigPath().Get() + defaultPath, ok := projectconfig.DefaultConfigPath().Get() assert.True(t, ok) origConfigBytes, err := os.ReadFile(defaultPath) assert.NoError(t, err) diff --git a/common/projectconfig/projectconfig.go b/common/projectconfig/projectconfig.go index e95f3163e7..0b598af666 100644 --- a/common/projectconfig/projectconfig.go +++ b/common/projectconfig/projectconfig.go @@ -44,7 +44,7 @@ func ConfigPaths(input []string) []string { if len(input) > 0 { return input } - path, ok := GetDefaultConfigPath().Get() + path, ok := DefaultConfigPath().Get() if !ok { return []string{} } @@ -55,7 +55,7 @@ func ConfigPaths(input []string) []string { return []string{path} } -func GetDefaultConfigPath() optional.Option[string] { +func DefaultConfigPath() optional.Option[string] { gitRoot, ok := internal.GitRoot("").Get() if !ok { return optional.None[string]() @@ -67,7 +67,7 @@ func GetDefaultConfigPath() optional.Option[string] { // does not already exist. func CreateDefaultFileIfNonexistent(ctx context.Context) error { logger := log.FromContext(ctx) - path, ok := GetDefaultConfigPath().Get() + path, ok := DefaultConfigPath().Get() if !ok { logger.Warnf("Failed to find Git root, so cannot verify whether an ftl-project.toml file exists there") return nil diff --git a/integration/actions.go b/integration/actions.go index fec8777ee1..ec9879c383 100644 --- a/integration/actions.go +++ b/integration/actions.go @@ -38,6 +38,15 @@ func Scaffold(src, dest string, tmplCtx any) Action { } } +// GitInit calls git init on the working directory. +func GitInit() Action { + return func(t testing.TB, ic TestContext) { + Infof("Running `git init` on the working directory: %s", ic.workDir) + err := ftlexec.Command(ic, log.Debug, ic.workDir, "git", "init", ic.workDir).RunBuffered(ic) + assert.NoError(t, err) + } +} + // Copy a module from the testdata directory to the working directory. // // Ensures that replace directives are correctly handled. diff --git a/integration/integration_test.go b/integration/integration_test.go index 69ceceaef3..f6c8a00a23 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -140,7 +140,8 @@ func TestRuntimeReflection(t *testing.T) { } func TestModuleUnitTests(t *testing.T) { - Run(t, "", + Run(t, "wrapped/ftl-project.toml", + GitInit(), CopyModule("time"), CopyModule("wrapped"), CopyModule("verbtypes"),