From dc0cc201412a2da2294691c65256d5381da654b0 Mon Sep 17 00:00:00 2001 From: p4u1 Date: Mon, 27 Oct 2025 20:13:46 +0100 Subject: [PATCH] fix(recipe): Prevent crash when recipe has no previous tag or release --- cli/recipe/sync.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 5e474743..f8fc19f6 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -42,7 +42,8 @@ local file system.`), ValidArgsFunction: func( cmd *cobra.Command, args []string, - toComplete string) ([]string, cobra.ShellCompDirective) { + toComplete string, + ) ([]string, cobra.ShellCompDirective) { switch l := len(args); l { case 0: return autocomplete.RecipeNameComplete() @@ -131,10 +132,16 @@ likely to change. log.Fatal(err) } - latestRelease := tags[len(tags)-1] + latestRelease := "0.0.0+0.0.0" + if len(tags) > 0 { + latestRelease = tags[len(tags)-1] + } changesTable.Headers(i18n.G("SERVICE"), latestRelease, i18n.G("PROPOSED CHANGES")) - latestRecipeVersion := versions[len(versions)-1] + latestRecipeVersion := latestRelease + if len(versions) > 0 { + latestRecipeVersion = versions[len(versions)-1] + } allRecipeVersions := catl[recipe.Name].Versions for _, recipeVersion := range allRecipeVersions { if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok {