mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix: address verified review findings (labels-milestones-time-1)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
21 files changed
+262
-47
No files matched your search
@@ -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 = ¤t.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)
|
||||
|
||||
Reference in new issue
Block a user