From 1c0af1c235a323a3fd5d5126f8c56213f40a9497 Mon Sep 17 00:00:00 2001 From: micnncim Date: Mon, 14 Oct 2019 09:33:48 +0900 Subject: [PATCH] Fix bug to prevent failing creating new label (#14) --- pkg/github/github.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/github/github.go b/pkg/github/github.go index 8026cac..c87410f 100644 --- a/pkg/github/github.go +++ b/pkg/github/github.go @@ -59,6 +59,22 @@ func (c *Client) SyncLabels(ctx context.Context, owner, repo string, labels []La eg := errgroup.Group{} + // Delete labels. + for _, currentLabel := range currentLabels { + currentLabel := currentLabel + eg.Go(func() error { + _, ok := labelMap[currentLabel.Name] + if ok { + return nil + } + return c.deleteLabel(ctx, owner, repo, currentLabel.Name) + }) + } + + if err := eg.Wait(); err != nil { + return err + } + // Create and/or update labels. for _, l := range labels { l := l @@ -74,18 +90,6 @@ func (c *Client) SyncLabels(ctx context.Context, owner, repo string, labels []La }) } - // Delete labels. - for _, currentLabel := range currentLabels { - currentLabel := currentLabel - eg.Go(func() error { - _, ok := labelMap[currentLabel.Name] - if ok { - return nil - } - return c.deleteLabel(ctx, owner, repo, currentLabel.Name) - }) - } - return eg.Wait() }