0
0
forked from toolshed/abra

fix(recipe): Prevent crash when recipe has no previous tag or release

This commit is contained in:
2025-10-27 20:13:46 +01:00
parent 11656c009d
commit dc0cc20141

View File

@ -42,7 +42,8 @@ local file system.`),
ValidArgsFunction: func( ValidArgsFunction: func(
cmd *cobra.Command, cmd *cobra.Command,
args []string, args []string,
toComplete string) ([]string, cobra.ShellCompDirective) { toComplete string,
) ([]string, cobra.ShellCompDirective) {
switch l := len(args); l { switch l := len(args); l {
case 0: case 0:
return autocomplete.RecipeNameComplete() return autocomplete.RecipeNameComplete()
@ -131,10 +132,16 @@ likely to change.
log.Fatal(err) 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")) 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 allRecipeVersions := catl[recipe.Name].Versions
for _, recipeVersion := range allRecipeVersions { for _, recipeVersion := range allRecipeVersions {
if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok { if serviceVersions, ok := recipeVersion[latestRecipeVersion]; ok {