mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 03:54:00 +09:00
Backport #39873 by @nazem-droubi Fixes #39651 When an org-owned repo has a repo label and an org label with the same name, `POST`/`PUT /repos/{owner}/{repo}/issues/{index}/labels` with label names attached both of them. With this change the repo label is used when the names collide, and org labels are only looked up for the names that didn't match a repo label. Names that only exist at the org level still resolve to the org label as before. I documented the behavior on `IssueLabelsOption.Labels` and regenerated the swagger files. Picking the repo label seemed the least surprising choice since it's the more specific one, but I'm happy to change it (for example to return a 422 on ambiguous names) if you'd prefer that. Tests: added `TestAPIAddIssueLabelsWithSharedRepoAndOrgLabelName`, which covers both POST and PUT. It fails on `main` (3 labels attached instead of 2) and passes with this change. I ran the existing add/replace label integration tests locally on sqlite, plus `go vet` and gofmt. AI disclosure: the code and test in this PR were written primarily by an AI coding agent working on my behalf. I'm happy to walk through it or revise anything during review. Signed-off-by: Nazem <214302554+nazem-droubi@users.noreply.github.com> Co-authored-by: Nazem <nazem98@gmail.com> Co-authored-by: Nazem <214302554+nazem-droubi@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io>
76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
// Copyright 2016 The Gogs Authors. All rights reserved.
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package structs
|
|
|
|
// Label a label to an issue or a pr
|
|
// swagger:model
|
|
type Label struct {
|
|
// ID is the unique identifier for the label
|
|
ID int64 `json:"id"`
|
|
// Name is the display name of the label
|
|
Name string `json:"name"`
|
|
// example: false
|
|
Exclusive bool `json:"exclusive"`
|
|
// example: false
|
|
IsArchived bool `json:"is_archived"`
|
|
// example: 00aabb
|
|
Color string `json:"color"`
|
|
// Description provides additional context about the label's purpose
|
|
Description string `json:"description"`
|
|
// URL is the API endpoint for accessing this label
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
// CreateLabelOption options for creating a label
|
|
type CreateLabelOption struct {
|
|
// required:true
|
|
// Name is the display name for the new label
|
|
Name string `json:"name" binding:"Required"`
|
|
// example: false
|
|
Exclusive bool `json:"exclusive"`
|
|
// required:true
|
|
// example: #00aabb
|
|
Color string `json:"color" binding:"Required"`
|
|
// Description provides additional context about the label's purpose
|
|
Description string `json:"description"`
|
|
// example: false
|
|
IsArchived bool `json:"is_archived"`
|
|
}
|
|
|
|
// EditLabelOption options for editing a label
|
|
type EditLabelOption struct {
|
|
// Name is the new display name for the label
|
|
Name *string `json:"name"`
|
|
// example: false
|
|
Exclusive *bool `json:"exclusive"`
|
|
// example: #00aabb
|
|
Color *string `json:"color"`
|
|
// Description provides additional context about the label's purpose
|
|
Description *string `json:"description"`
|
|
// example: false
|
|
IsArchived *bool `json:"is_archived"`
|
|
}
|
|
|
|
// IssueLabelsOption a collection of labels
|
|
type IssueLabelsOption struct {
|
|
// Labels can be a list of integers representing label IDs
|
|
// or a list of strings representing label names.
|
|
// If a repository label and an organization label share a name,
|
|
// the repository label is used.
|
|
Labels []any `json:"labels"`
|
|
}
|
|
|
|
// LabelTemplate info of a Label template
|
|
type LabelTemplate struct {
|
|
// Name is the display name of the label template
|
|
Name string `json:"name"`
|
|
// example: false
|
|
Exclusive bool `json:"exclusive"`
|
|
// example: 00aabb
|
|
Color string `json:"color"`
|
|
// Description provides additional context about the label template's purpose
|
|
Description string `json:"description"`
|
|
}
|