From 992e675921a316c93f6775b1dc5e86327ce2af17 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 15 Feb 2023 00:35:33 +0100 Subject: [PATCH] refactor: use passed down conf to decide --- cli/internal/validate.go | 12 ++++-------- pkg/recipe/recipe.go | 4 ++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/internal/validate.go b/cli/internal/validate.go index 36f72679..7a66444d 100644 --- a/cli/internal/validate.go +++ b/cli/internal/validate.go @@ -42,10 +42,8 @@ func ValidateRecipe(c *cli.Context, opts ...runtime.Option) recipe.Recipe { } } - if conf.EnsureRecipeLatest { - if err := recipe.EnsureLatest(recipeName, conf); err != nil { - logrus.Fatal(err) - } + if err := recipe.EnsureLatest(recipeName, conf); err != nil { + logrus.Fatal(err) } logrus.Debugf("validated %s as recipe argument", recipeName) @@ -110,10 +108,8 @@ func ValidateRecipeWithPrompt(c *cli.Context, opts ...runtime.Option) recipe.Rec logrus.Fatal(err) } - if conf.EnsureRecipeLatest { - if err := recipe.EnsureLatest(recipeName, conf); err != nil { - logrus.Fatal(err) - } + if err := recipe.EnsureLatest(recipeName, conf); err != nil { + logrus.Fatal(err) } logrus.Debugf("validated %s as recipe argument", recipeName) diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index d7b015ae..cd47f820 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -339,6 +339,10 @@ func EnsureVersion(recipeName, version string) error { // EnsureLatest makes sure the latest commit is checked out for a local recipe repository func EnsureLatest(recipeName string, conf *runtime.Config) error { + if !conf.EnsureRecipeLatest { + return nil + } + recipeDir := path.Join(config.RECIPES_DIR, recipeName) isClean, err := gitPkg.IsClean(recipeDir)