From 71a91550426d845c5cce64321f81a77e19fe45cc Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 2 Feb 2023 20:58:38 +0100 Subject: [PATCH] fix: specify refs when fetching tags See https://git.coopcloud.tech/coop-cloud/organising/issues/397 --- pkg/recipe/recipe.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index c81d693f..816aa55e 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -24,6 +24,7 @@ import ( composetypes "github.com/docker/cli/cli/compose/types" "github.com/docker/distribution/reference" "github.com/go-git/go-git/v5" + gitConfig "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" "github.com/sirupsen/logrus" ) @@ -616,9 +617,17 @@ func EnsureUpToDate(recipeName string) error { return err } - fetchOpts := &git.FetchOptions{Tags: git.AllTags} + fmt.Println(branch) + fetchOpts := &git.FetchOptions{ + Tags: git.AllTags, + RefSpecs: []gitConfig.RefSpec{ + gitConfig.RefSpec(fmt.Sprintf("%s:%s", branch, branch)), + }, + } if err := repo.Fetch(fetchOpts); err != nil { - return err + if !strings.Contains(err.Error(), "already up-to-date") { + return err + } } opts := &git.PullOptions{