Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions internal/github/pull_request_provider.go
Comment thread
adriangarcia-nesto marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package github

import (
"bytes"
"encoding/json"
"fmt"
"os/exec"
Expand Down Expand Up @@ -214,9 +215,14 @@ func (p *PullRequestProvider) createLabels(labels ...string) error {
return fmt.Errorf("listing labels: %s", output)
}

// `gh label list --json` returns empty output when the repo has no labels,
// which is not valid JSON and would fail to unmarshal.
output = bytes.TrimSpace(output)
var existingLabels []label
if err := json.Unmarshal(output, &existingLabels); err != nil {
return fmt.Errorf("unmarshaling label list: %w", err)
if len(output) > 0 {
if err := json.Unmarshal(output, &existingLabels); err != nil {
return fmt.Errorf("unmarshaling label list: %w", err)
}
}
existingLabelSet := make(map[string]bool)
for _, existingLabel := range existingLabels {
Expand Down
Loading