summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-01 21:57:34 -0500
committerGitHub <noreply@github.com>2023-03-01 21:57:34 -0500
commit5d5f907e7fcf1dee4eaca205f8e43f50e5884a58 (patch)
tree8c19d3389f5824c88ed66e3d9a096da9a43956d9 /services
parent39178b57561110737a54c8ba52d5e96640804df8 (diff)
downloadgitea-5d5f907e7fcf1dee4eaca205f8e43f50e5884a58.tar.gz
gitea-5d5f907e7fcf1dee4eaca205f8e43f50e5884a58.zip
Add loading yaml label template files (#22976) (#23232)
Backport #22976 Extract from #11669 and enhancement to #22585 to support exclusive scoped labels in label templates * Move label template functionality to label module * Fix handling of color codes * Add Advanced label template Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'services')
-rw-r--r--services/migrations/gitea_uploader.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/services/migrations/gitea_uploader.go b/services/migrations/gitea_uploader.go
index 20370d99f9..8b259a362b 100644
--- a/services/migrations/gitea_uploader.go
+++ b/services/migrations/gitea_uploader.go
@@ -21,6 +21,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
+ "code.gitea.io/gitea/modules/label"
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
repo_module "code.gitea.io/gitea/modules/repository"
@@ -217,18 +218,20 @@ func (g *GiteaLocalUploader) CreateMilestones(milestones ...*base.Milestone) err
// CreateLabels creates labels
func (g *GiteaLocalUploader) CreateLabels(labels ...*base.Label) error {
lbs := make([]*issues_model.Label, 0, len(labels))
- for _, label := range labels {
- // We must validate color here:
- if !issues_model.LabelColorPattern.MatchString("#" + label.Color) {
- log.Warn("Invalid label color: #%s for label: %s in migration to %s/%s", label.Color, label.Name, g.repoOwner, g.repoName)
- label.Color = "ffffff"
+ for _, l := range labels {
+ if color, err := label.NormalizeColor(l.Color); err != nil {
+ log.Warn("Invalid label color: #%s for label: %s in migration to %s/%s", l.Color, l.Name, g.repoOwner, g.repoName)
+ l.Color = "#ffffff"
+ } else {
+ l.Color = color
}
lbs = append(lbs, &issues_model.Label{
RepoID: g.repo.ID,
- Name: label.Name,
- Description: label.Description,
- Color: "#" + label.Color,
+ Name: l.Name,
+ Exclusive: l.Exclusive,
+ Description: l.Description,
+ Color: l.Color,
})
}