diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index 7a695fd3..f34337f1 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -1,6 +1,7 @@ package recipe import ( + "errors" "fmt" "os" "strings" @@ -67,6 +68,9 @@ func (r Recipe) EnsureExists() error { // EnsureVersion checks whether a specific version exists for a recipe. func (r Recipe) EnsureVersion(version string) (bool, error) { + if strings.Contains(version, "+ unstaged changes") { + return true, errors.New("A chaos version is configured. \nMaybe your coworker deployed a local version of the recipe?\nOr did you forget to add --chaos?") + } isChaosCommit := false if err := gitPkg.EnsureGitRepo(r.Dir); err != nil { diff --git a/tests/integration/app_deploy_env_version.bats b/tests/integration/app_deploy_env_version.bats index 0522ea05..d56ccc30 100644 --- a/tests/integration/app_deploy_env_version.bats +++ b/tests/integration/app_deploy_env_version.bats @@ -25,6 +25,17 @@ teardown(){ _reset_app } +# bats test_tags=slow +@test "fails to deploy + unstaged changes version" { + run sed -i 's/TYPE=abra-test-recipe.*/TYPE=git.coopcloud.tech\/coop-cloud\/abra-test-recipe:111111 + unstaged changes/g' \ + "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env" + assert_success + + run $ABRA app deploy "$TEST_APP_DOMAIN" --no-input + assert_failure + assert_output --partial 'A chaos version is configured. \nMaybe your coworker deployed a local version of the recipe?\nOr did you forget to add --chaos?' +} + # bats test_tags=slow @test "deploy version written to env" { run $ABRA app deploy "$TEST_APP_DOMAIN" "0.1.0+1.20.0" --no-input --no-converge-checks