Skip to content

Commit

Permalink
labels: don't fetch labels in case of empty request
Browse files Browse the repository at this point in the history
Check if any label is being really requested before fetching project's
information. This patch improves `list` and `edit` queries by a lot, depending
on the number of labels present in the project.

Signed-off-by: Bruno Meneguele <[email protected]>
  • Loading branch information
bmeneg committed Apr 8, 2021
1 parent 41e9f74 commit 898dff8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/label_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ lab label list remote "search term" # search "remote" for labels with "search t
}

func MapLabels(rn string, labelTerms []string) ([]string, error) {
// Don't bother fetching project labels if nothing is being really requested
if len(labelTerms) == 0 {
return []string{}, nil
}

labels, err := lab.LabelList(rn)
if err != nil {
return nil, err
Expand Down

0 comments on commit 898dff8

Please sign in to comment.