From c2a3f0694c76e8685be49bb5100d5649c8d8c8ef Mon Sep 17 00:00:00 2001 From: Safeer Jiwan Date: Wed, 5 Jun 2024 15:00:08 -0700 Subject: [PATCH] fix: correctly use gitroot optional --- buildengine/engine.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/buildengine/engine.go b/buildengine/engine.go index 8d63c8ffe9..5cf7114c7f 100644 --- a/buildengine/engine.go +++ b/buildengine/engine.go @@ -180,23 +180,31 @@ func (e *Engine) Close() error { } func createLockFile() (string, error) { - lockFile := filepath.Join(internal.GitRoot(""), "_ftl", "build.lock") + gitRoot, ok := internal.GitRoot("").Get() + if !ok { + return "", fmt.Errorf("could not get git root") + } + lockFile := filepath.Join(gitRoot, "_ftl", "build.lock") if err := os.MkdirAll(filepath.Dir(lockFile), 0750); err != nil { - return "", fmt.Errorf("failed to create directory for build.lock file: %w", err) + return "", err } if _, err := os.Stat(lockFile); err == nil || !errors.Is(err, os.ErrNotExist) { return "", fmt.Errorf("build.lock file already exists at: %s", lockFile) } if err := os.WriteFile(lockFile, []byte(""), 0640); err != nil { - return "", fmt.Errorf("failed to write build.lock file: %w", err) + return "", err } return lockFile, nil } func deleteLockFile() error { - lockFile := filepath.Join(internal.GitRoot(""), "_ftl", "build.lock") + gitRoot, ok := internal.GitRoot("").Get() + if !ok { + return fmt.Errorf("could not get git root") + } + lockFile := filepath.Join(gitRoot, "_ftl", "build.lock") if err := os.Remove(lockFile); err != nil { - return fmt.Errorf("failed to remove build.lock file: %w", err) + return err } return nil }