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

+17 -2
View File
@@ -35,6 +35,15 @@ type LabelOptions struct {
Archived *bool `json:"is_archived,omitempty"`
}
// KeepArchived returns opts with the archived state of current unless opts sets one: Gitea
// unarchives a label whose edit leaves is_archived out.
func (opts LabelOptions) KeepArchived(current Label) LabelOptions {
if opts.Archived == nil {
opts.Archived = &current.Archived
}
return opts
}
// Labels implements explicitly scoped label operations.
type Labels struct {
Client *transport.Client
@@ -84,8 +93,14 @@ func (s Labels) Create(ctx context.Context, opts LabelOptions) (Label, error) {
if s.Organization != "" && opts.Archived != nil && *opts.Archived {
// TODO(sdk): CreateOrgLabelOption.IsArchived
var result Label
err := sendJSON(ctx, s.Client, http.MethodPost, s.orgEndpoint(), opts, &result)
return result, err
if err := sendJSON(ctx, s.Client, http.MethodPost, s.orgEndpoint(), opts, &result); err != nil {
return result, err
}
if !result.Archived {
// Gitea ignores is_archived when it creates an organization label.
return s.Edit(ctx, result.ID, LabelOptions{Archived: opts.Archived})
}
return result, nil
}
name, color, description := deref(opts.Name), deref(opts.Color), deref(opts.Description)
exclusive, archived := deref(opts.Exclusive), deref(opts.Archived)