mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-25 22:27:39 +02:00
fix(labels): add org label for ls and pr (#1017)
Fix https://gitea.com/gitea/tea/issues/634, https://gitea.com/gitea/tea/issues/669 Reviewed-on: https://gitea.com/gitea/tea/pulls/1017 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Minjie Fang <wingsallen@gmail.com> Co-committed-by: Minjie Fang <wingsallen@gmail.com>
This commit is contained in:
@@ -5,8 +5,9 @@ package print
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gitea.dev/sdk"
|
||||
gitea "gitea.dev/sdk"
|
||||
)
|
||||
|
||||
// LabelsList prints a listing of labels
|
||||
@@ -16,14 +17,20 @@ func LabelsList(labels []*gitea.Label, output string) error {
|
||||
"Color",
|
||||
"Name",
|
||||
"Description",
|
||||
"Level",
|
||||
)
|
||||
|
||||
for _, label := range labels {
|
||||
level := "Repository"
|
||||
if strings.Contains(label.URL, "/orgs/") {
|
||||
level = "Organization"
|
||||
}
|
||||
t.addRow(
|
||||
strconv.FormatInt(label.ID, 10),
|
||||
formatLabel(label, !isMachineReadable(output), label.Color),
|
||||
label.Name,
|
||||
label.Description,
|
||||
level,
|
||||
)
|
||||
}
|
||||
return t.print(output)
|
||||
|
||||
@@ -23,6 +23,16 @@ func ResolveLabelNames(requestCtx stdctx.Context, client *gitea.Client, owner, r
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, _, err := client.Organizations.GetOrg(requestCtx, owner); err == nil {
|
||||
orgLabels, _, err := client.Organizations.ListOrgLabels(requestCtx, owner, gitea.ListOrgLabelsOptions{
|
||||
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
labels = append(labels, orgLabels...)
|
||||
}
|
||||
|
||||
for _, l := range labels {
|
||||
if utils.Contains(labelNames, l.Name) {
|
||||
labelIDs = append(labelIDs, l.ID)
|
||||
|
||||
Reference in New Issue
Block a user