Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
  • Loading branch information
milldr and osterman authored Jan 31, 2025
1 parent f6379fa commit abfbd2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cmd/cmd_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 failure on line 639 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, linux)

cannot use nil as bool value in return statement

Check failure on line 639 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (windows-latest, windows)

cannot use nil as bool value in return statement

Check failure on line 639 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (macos-latest, macos)

cannot use nil as bool value in return statement
}

// 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
}
}

Check failure on line 648 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest, linux)

missing return

Check failure on line 648 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (windows-latest, windows)

missing return

Check failure on line 648 in cmd/cmd_utils.go

View workflow job for this annotation

GitHub Actions / Build (macos-latest, macos)

missing return
4 changes: 2 additions & 2 deletions tests/test-cases/empty-dir.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit abfbd2d

Please sign in to comment.