From 91460340ebe761cf41e7f5c15f8833a364d32151 Mon Sep 17 00:00:00 2001 From: Chris Gavin Date: Wed, 6 Apr 2022 16:22:08 +0100 Subject: [PATCH] Check release references exist in the cache before trying to push them. --- internal/push/push.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/push/push.go b/internal/push/push.go index f1413f2..9ddebf0 100644 --- a/internal/push/push.go +++ b/internal/push/push.go @@ -215,7 +215,12 @@ func (pushService *pushService) pushGit(repository *github.Repository, initialPu } initialRefSpecs := []config.RefSpec{} for _, releasePathStat := range releasePathStats { - initialRefSpecs = append(initialRefSpecs, config.RefSpec("+refs/tags/"+releasePathStat.Name()+":refs/tags/"+releasePathStat.Name())) + tagReferenceName := plumbing.NewTagReferenceName(releasePathStat.Name()) + _, err := gitRepository.Reference(tagReferenceName, true) + if err != nil { + return errors.Wrapf(err, "Error finding local tag reference %s.", tagReferenceName) + } + initialRefSpecs = append(initialRefSpecs, config.RefSpec("+"+tagReferenceName.String()+":"+tagReferenceName.String())) } refSpecBatches = append(refSpecBatches, initialRefSpecs) } else {