Skip to content

Commit

Permalink
Fix bug to prevent failing creating new label (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
micnncim committed Oct 14, 2019
1 parent 0a676ef commit 1c0af1c
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions pkg/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}

Expand Down

0 comments on commit 1c0af1c

Please sign in to comment.