diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index fe67ddf33e..fac80ec31b 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -632,15 +632,17 @@ func isGitRepository() bool { return true } -// checkGitAndEnvVars checks if we're at the root of a git repo and if required env vars are set -func checkGitAndEnvVars() { +// verifyInsideGitRepo checks if we're at the root of a git repo, if required env vars are not set +func verifyInsideGitRepo() bool { // Skip check if either env var is set if os.Getenv("ATMOS_BASE_PATH") != "" || os.Getenv("ATMOS_CLI_CONFIG_PATH") != "" { - return + return nil } // Check if we're at the root of a git repo if !isGitRepository() { u.LogWarning(atmosConfig, "You're not at the root of a git repository. Atmos feels lonely outside - bring it home!\n") + return false + return true } } diff --git a/tests/test-cases/empty-dir.yaml b/tests/test-cases/empty-dir.yaml index 9fae74195e..d68ad8d0f9 100644 --- a/tests/test-cases/empty-dir.yaml +++ b/tests/test-cases/empty-dir.yaml @@ -47,10 +47,10 @@ tests: - "^$" exit_code: 0 - - name: run atmos outside git repo + - name: atmos warns if not in git repo enabled: true snapshot: true - description: "Test checkGitAndEnvVars function outside of a git repo with ATMOS_LOGS_LEVEL=Warn" + description: "Test that atmos warns if not run inside of a git repo" workdir: "fixtures/scenarios/empty-dir" command: "atmos" args: