Skip to content

Commit

Permalink
merge existing labels because Edit api replaces its labels
Browse files Browse the repository at this point in the history
  • Loading branch information
everpeace committed Dec 2, 2020
1 parent a683649 commit 990b961
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/notifier/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ func (n *GitHubNotifier) Notify(ctx context.Context, payload *types.WebhookPaylo
}
log.Info().Msg("created an issue")
} else {
// we have to merge existing labels because Edit api replaces its labels
mergedLabels := []string{}
labelSet := map[string]bool{}
for _, l := range issue.Labels {
name := *l.Name
if !labelSet[name] {
labelSet[name] = true
mergedLabels = append(mergedLabels, name)
}
}
for _, l := range labels {
if !labelSet[l] {
labelSet[l] = true
mergedLabels = append(mergedLabels, l)
}
}
req.Labels = &mergedLabels
issue, _, err = n.GitHubClient.Issues.Edit(ctx, owner, repo, issue.GetNumber(), req)
if err != nil {
return err
Expand Down

0 comments on commit 990b961

Please sign in to comment.