diff --git a/cli/recipe/release.go b/cli/recipe/release.go index df3c5bd4..fb3d22e7 100644 --- a/cli/recipe/release.go +++ b/cli/recipe/release.go @@ -97,7 +97,7 @@ your SSH keys configured on your account. } } - tags, err := recipe.Tags() + tags, err := r.Tags() if err != nil { log.Fatal(err) } diff --git a/cli/recipe/sync.go b/cli/recipe/sync.go index 0e0ef874..b671f028 100644 --- a/cli/recipe/sync.go +++ b/cli/recipe/sync.go @@ -59,7 +59,7 @@ local file system. mainAppVersion := imagesTmp[mainApp] - tags, err := recipe.Tags() + tags, err := r.Tags() if err != nil { log.Fatal(err) } diff --git a/pkg/recipe/git.go b/pkg/recipe/git.go index ba1b0972..9df862e4 100644 --- a/pkg/recipe/git.go +++ b/pkg/recipe/git.go @@ -262,3 +262,29 @@ func (r Recipe2) Push(dryRun bool) error { return nil } + +// Tags list the recipe tags +func (r Recipe2) Tags() ([]string, error) { + var tags []string + + repo, err := git.PlainOpen(r.Dir) + if err != nil { + return tags, err + } + + gitTags, err := repo.Tags() + if err != nil { + return tags, err + } + + if err := gitTags.ForEach(func(ref *plumbing.Reference) (err error) { + tags = append(tags, strings.TrimPrefix(string(ref.Name()), "refs/tags/")) + return nil + }); err != nil { + return tags, err + } + + log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name) + + return tags, nil +} diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 3a3d83d5..976b0a71 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -141,32 +141,6 @@ func (r Recipe) Dir() string { return path.Join(config.RECIPES_DIR, r.Name) } -// Tags list the recipe tags -func (r Recipe) Tags() ([]string, error) { - var tags []string - - repo, err := git.PlainOpen(r.Dir()) - if err != nil { - return tags, err - } - - gitTags, err := repo.Tags() - if err != nil { - return tags, err - } - - if err := gitTags.ForEach(func(ref *plumbing.Reference) (err error) { - tags = append(tags, strings.TrimPrefix(string(ref.Name()), "refs/tags/")) - return nil - }); err != nil { - return tags, err - } - - log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name) - - return tags, nil -} - // Get retrieves a recipe. func Get(recipeName string, offline bool) (Recipe, error) { r := Get2(recipeName)