fix: address verified review findings (labels-milestones-time-1)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:40:59 +02:00
1 parent be3b8a1ced
commit e28bb6e039
21 files changed
+262 -47

No files matched your search

+13 -7
View File
@@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"math/rand/v2"
"slices"
"strconv"
"strings"
@@ -166,10 +167,6 @@ $ tea label create bug -c ee0701 --force`, Args: usageArgs(cobra.MaximumNArgs(1)
return err
}
}
if opts.Color == nil {
color := labelColors[rand.IntN(len(labelColors))]
opts.Color = &color
}
s, err := scope(cmd)
if err != nil {
return err
@@ -178,6 +175,11 @@ $ tea label create bug -c ee0701 --force`, Args: usageArgs(cobra.MaximumNArgs(1)
if err != nil {
return err
}
// A random color is for new labels; --force keeps the color of an existing one.
if opts.Color == nil && !slices.ContainsFunc(existing, func(l services.Label) bool { return strings.EqualFold(l.Name, fields.name) }) {
color := labelColors[rand.IntN(len(labelColors))]
opts.Color = &color
}
item, updated, err := s.CreateUnique(cmd.Context(), existing, opts, force)
if err != nil {
return forceHint(err)
@@ -242,7 +244,7 @@ $ tea label edit old-stuff --archived`, Annotations: map[string]string{"tea.argu
return err
}
if opts == (services.LabelOptions{}) {
return errNothingToEdit
return clierr.Wrap(clierr.Usage, errors.New("nothing to edit; pass a flag such as --name or --color (see --help)"))
}
s, err := scope(cmd)
if err != nil {
@@ -252,7 +254,7 @@ $ tea label edit old-stuff --archived`, Annotations: map[string]string{"tea.argu
if err != nil {
return err
}
item, err := s.Edit(cmd.Context(), found[0].ID, opts)
item, err := s.Edit(cmd.Context(), found[0].ID, opts.KeepArchived(found[0]))
if err != nil {
return err
}
@@ -345,7 +347,11 @@ func (a *application) importLabels(cmd *cobra.Command, scope labelScope, file st
}, func(item services.Label) {
a.done(cmd, "%s %s", outcome[item.Name], labelName(s, item))
})
return errors.Join(append(failures, writeBatchJSON(a, cmd, len(rows), results))...)
// The shape of the output must not depend on how many rows the file has.
if a.options.json != "" {
failures = append(failures, a.writeJSON(cmd, results))
}
return errors.Join(failures...)
}
// completeScopedLabels completes the label names of the repository or, with --org, of the