From 742a7267781a9a80971ef38cfc96d1a03c6ace7c Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 14 Apr 2025 11:36:50 +0200 Subject: [PATCH] fix: latest commit for new recipe version See https://git.coopcloud.tech/toolshed/abra/issues/527 --- cli/app/new.go | 7 +++++++ tests/integration/recipe_new.bats | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/cli/app/new.go b/cli/app/new.go index 72c25e68..13e9c831 100644 --- a/cli/app/new.go +++ b/cli/app/new.go @@ -109,6 +109,13 @@ var AppNewCommand = &cobra.Command{ if err := recipe.EnsureLatest(); err != nil { log.Fatal(err) } + + head, err := recipe.Head() + if err != nil { + log.Fatalf("failed to retrieve latest commit for %s: %s", recipe.Name, err) + } + + recipeVersion = formatter.SmallSHA(head.String()) } } diff --git a/tests/integration/recipe_new.bats b/tests/integration/recipe_new.bats index f1e11270..49cb167b 100644 --- a/tests/integration/recipe_new.bats +++ b/tests/integration/recipe_new.bats @@ -68,3 +68,27 @@ teardown(){ assert_output --partial 'fooUser' assert_output --partial 'foo@example.com' } + +# bats test_tags=slow +@test "recipe new, app new, no releases, latest commit" { + recipeName="foobar" + + run $ABRA recipe new "$recipeName" + assert_success + assert_exists "$ABRA_DIR/recipes/$recipeName" + + currentHash=$(git -C "$ABRA_DIR/recipes/$recipeName" show -s --format="%H") + domain="$recipeName.$TEST_APP_SERVER" + + run $ABRA app new "$recipeName" \ + --no-input \ + --server "$TEST_SERVER" \ + --domain "$domain" + assert_success + assert_output --partial "version: ${currentHash:0:8}" + assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$domain.env" + + run grep -q "TYPE=$recipeName:${currentHash:0:8}" \ + "$ABRA_DIR/servers/$TEST_SERVER/$domain.env" + assert_success +}