fix: latest commit for new recipe version
All checks were successful
continuous-integration/drone/push Build is passing

See #527
This commit is contained in:
decentral1se 2025-04-14 11:36:50 +02:00
parent 2b9a185aff
commit 742a726778
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
2 changed files with 31 additions and 0 deletions

View File

@ -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())
}
}

View File

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