fix: show latest commit on new recipe without versions
All checks were successful
continuous-integration/drone/push Build is passing

See #527
This commit is contained in:
2025-04-14 10:01:49 +02:00
parent 2b9a185aff
commit 5cbe5cf7b7
2 changed files with 28 additions and 0 deletions

View File

@ -185,6 +185,15 @@ var AppNewCommand = &cobra.Command{
newAppServer = "local"
}
if recipeVersion == "" {
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())
}
log.Infof("%s created (version: %s)", appDomain, recipeVersion)
if len(appSecrets) > 0 {

View File

@ -250,3 +250,22 @@ teardown(){
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}
# bats test_tags=slow
@test "app new, no releases, latest commit" {
currentHash=$(_get_current_hash)
_remove_tags
run $ABRA app new "$TEST_RECIPE" \
--no-input \
--server "$TEST_SERVER" \
--domain "$TEST_APP_DOMAIN" \
--secrets \
assert_success
assert_exists "$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
# assert_output --partial "version: ${currentHash:0:8}"
run grep -q "TYPE=$TEST_RECIPE:${currentHash:0:8}" \
"$ABRA_DIR/servers/$TEST_SERVER/$TEST_APP_DOMAIN.env"
assert_success
}